简体   繁体   English

使用pip并通过多个python安装来安装软件包

[英]Installing packages with pip with multiple python installs

I have been using Anaconda python on Windows 7, but a package I need isn't supported by Anaconda python, so I installed CPython from python.org. 我一直在Windows 7上使用Anaconda python,但是Anaconda python不支持我需要的软件包,因此我从python.org安装了CPython。 I'd like to install the package to CPython, but pip still installs everything to C:\\Anaconda\\ ...\\site-packages . 我想将软件包安装到CPython,但是pip仍然将所有内容安装到C:\\Anaconda\\ ...\\site-packages How can I change this? 我该如何更改?

Just change your PATH environment variable to put C:\\PythonXX\\Scripts (where XX is the version of Python, usually 27 or 34 ) at the beginning. 只需更改PATH环境变量,即可将C:\\PythonXX\\Scripts (其中XX是Python的版本,通常为2734 )放在开头。

Click on My Computer -> Properties -> System Properties -> Advanced -> Environment Variables , then select Path in either the System Variables section (if you have Administrator access), or User Variables if you don't. 单击“ My Computer -> Properties -> System Properties -> Advanced -> Environment Variables ,然后在“ System Variables部分(如果您具有管理员权限)或“ User Variables选择“ Path Click Edit and put the correct path at the beginning, followed by a semi-colon ; 单击“ 编辑” ,然后将正确的路径放在开头,然后是分号; . Save everything, close your command line session(s), then start a new one. 保存所有内容,关闭命令行会话,然后开始一个新的会话。 Running pip -V should now print the CPython version and location instead of the Anaconda one. 现在运行pip -V应该打印CPython版本和位置,而不是Anaconda。

If you have Anaconda installed, an easier way to modify your PATH is to use the activate and deactivate scripts. 如果安装了Anaconda,则修改PATH的一种简便方法是使用activatedeactivate脚本。

activate envname

will put the envname environment on your PATH, and envname环境放在您的PATH上,并且

deactivate

will remove it. 将其删除。

Hence, you just need to call activate before calling pip . 因此,你只需要调用activate调用之前pip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM