如何避免Anaconda劫持pip。

16 浏览
0 Comments

如何避免Anaconda劫持pip。

我在我的电脑上安装了两个版本的Python(Windows 7,64位)。Anaconda安装了Python 2.7版本,而直接从python.org安装了Python 3.6版本(即“常规IDLE”)。现在,我想使用pip在3.6上安装必要的包,但是Anaconda一直在干扰这个命令。例如,在cmd窗口中键入:

pip install numpy

然后我得到:

要求已经满足:numpy 在 c:\users\georges\anaconda2\lib\site_packages

这是针对Python 2.7的情况,但我想要安装的是没有使用Anaconda安装的3.6版本。我尝试重新安装pip,希望它能消除Anaconda2的干扰...但失败了。我正在考虑彻底删除Anaconda2,尽管这样做可能会导致Windows中的程序依赖关系没有被完全删除。请问有什么建议吗?

0
0 Comments

出现原因:Anaconda安装后会将自带的Python版本与pip绑定,使用pip安装包时可能会出现Anaconda版本的Python与系统Python冲突的情况。

解决方法:安装pip3来代替Anaconda绑定的pip,这样就可以在Python3环境下安装包。

首先使用where pip3命令检查是否已经安装了pip3,如果没有安装则需要进行安装。

可以参考这篇帖子来解决进一步的问题。

不需要卸载Anaconda2,因为两个Python版本可以共存,并且可以使用不同的包管理器pip和pip3来管理不同版本的库。

希望这个回答可以解决你的问题。

0
0 Comments

Anaconda is a popular distribution of Python that comes with its own package manager called conda. However, sometimes Anaconda can interfere with the normal operation of pip, the default package manager for Python.

When installing packages using pip, Anaconda may hijack the process and try to install the package using its own conda package manager. This can lead to compatibility issues and package conflicts, especially if you are using pip for a specific Python version while Anaconda is designed for a different version.

To avoid Anaconda hijacking pip, you can use the pip3 command instead of pip. The pip3 command is specifically designed for Python 3, which is the most commonly used version of Python. By using pip3, you can ensure that Anaconda does not interfere with the installation process.

Here is an example of how to install the numpy package using pip3:

pip3 install numpy

By using pip3 instead of pip, you can prevent Anaconda from hijacking the installation process and ensure that the package is installed correctly for Python 3.

In summary, to avoid Anaconda hijacking pip, use the pip3 command when installing packages for Python 3. This will ensure compatibility and prevent any conflicts between Anaconda and pip.

0