pycharm中通过File -> Settings... -> Project: -> Project Interpreter,然后添加依赖包,但是总是有问题,后面在cmd窗口中执行命令来安装,但是报ReadTimeoutError错误,后面参考了文章<Make sure that you use the correct version of 'pip' installed for your Python interpreter>,加上国内的源"-i http://pypi.douban.com/simple --trusted-host pypi.douban.com"就可以了。
如果报错"ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'c:\\program files\\python\\python37\\Lib\\site-packages\\itsdangerous' Consider using the `--user` option or check the permissions.",则以管理员身份运行dos窗口即可。
如果管理员身份启动了dos窗口后,直接执行pip install 貌似安装到了c:\\program files\\python\\python37\\Lib\\site-packages目录下,如上面提示的错误所述,如果在Pycharm中指定了一个Project Interpreter,在需要在cmd中cd到对应的Interpreter的bin文件所在目录下,比如D:\pythonWork\env\Scripts,一般地,用一个通用的Interpreter来做所有的项目的解释器,而不是在每个项目下都创建一个env目录的解释器,这样可以避免重复安装依赖包。
CentOS7默认安装python2.7,后来参考了文章<CentOS7安装Python3的教程详解>在centos上安装了python3.7.4。