[英]Site-Packages in Python2.7 without VirtualEnv
When I use pip install matplotlib --upgrade
it runs and installs matplotlib
and all dependicies, and at the end reads uninstalled version '1.3.1'
. 当我使用
pip install matplotlib --upgrade
--upgrade时,它将运行并安装matplotlib
和所有依赖项,最后读取已uninstalled version '1.3.1'
。 Running python and matplotlib.__version__
outputs '1.3.1'
again, even though it was just declared uninstalled. 运行python和
matplotlib.__version__
再次输出'1.3.1'
,即使它刚刚被声明为已卸载。 How do I switch which python I'm running from, which would hopefully be where pip
is installing and updating packages? 如何切换运行的python,希望是
pip
安装和更新软件包的位置?
Edit: Running Mac OS 10.10.1, using python from bash. 编辑:从bash使用python运行Mac OS 10.10.1。
which pip
returns /usr/local/bin/pip
and which -a python
returns which pip
返回/usr/local/bin/pip
以及which -a python
返回
/opt/local/bin/python
/opt/local/bin/python
/Library/Frameworks/Python.framework/Versions/Current/bin/python
/Library/Frameworks/Python.framework/Versions/Current/bin/python
/Library/Frameworks/Python.framework/Versions/Current/bin/python
/Library/Frameworks/Python.framework/Versions/2.6/bin/python
/usr/bin/python
which I'm assuming is the problem. 我假设是问题所在。 I've deleted 2.6 before, but my Mac uses it and I had to restore my OS.
我之前已经删除了2.6,但是我的Mac使用了它,因此不得不还原操作系统。 How do I switch amongst them.
如何在它们之间切换。
Your problem appears to be that you have two or more Python 2.7 installations, and the first python
on the PATH comes from one installation (the MacPorts version, at /opt/local/bin/python
), while the first pip
on the PATH comes from a different one (you haven't said which, but I'd guess it's /usr/local/bin/pip
, and it's attached to either the pre-installed Apple Python or yet another Python). 您的问题似乎是您有两个或多个Python 2.7安装,并且PATH上的第一个
python
来自一个安装(MacPorts版本,位于/opt/local/bin/python
),而PATH上的第一个pip
来了来自另一个(您还没有说出来,但我想它是/usr/local/bin/pip
,它已连接到预安装的Apple Python或另一个Python)。
If you want to have lots of Pythons installed all over the filesystem and switch among them without using virtualenv
, you just need to write some scripts with modify your PATH
. 如果要在整个文件系统上安装大量Python,并在不使用
virtualenv
情况下在它们之间进行切换,则只需编写一些脚本并修改PATH
。 (And your PYTHONPATH
, if you use one… but hopefully you don't.) (还有您的
PYTHONPATH
,如果您使用的是…,但希望您不要。)
But I wouldn't recommend that. 但我不建议这样做。 If you want to use the MacPorts Python:
如果要使用MacPorts Python:
pip
installed (it should be in /opt/local/bin/pip
). pip
(应该在/opt/local/bin/pip
)。 I don't know if MacPorts has a separate python-pip
package, or expects you to install it manually , or otherwise. python-pip
程序包,或者期望您手动安装它 ,否则。 pip
installed. pip
之后打开一个新的Terminal窗口。 Or, to be safe, just explicitly use /opt/local/bin/pip
until the next time you logout and back in. /opt/local/bin/pip
直到下次注销并重新登录。 #!/opt/local/bin/python
instead of #!/usr/bin/env python
. #!/opt/local/bin/python
而不是#!/usr/bin/env python
。 port install python-ipython
or port install python27-ipython
, and only fall back to pip
if there is no portfile. port install python-ipython
或port install python27-ipython
,并且只有在没有portfile时才回退到pip
。 As a side note, many people who have this problem also have MacPorts colliding with Homebrew (or sometimes Fink, gentoo-alt, or other package managers, but none of them are very common nowadays). 附带说明一下,许多有此问题的人也使MacPorts与Homebrew冲突(有时甚至是Fink,gentoo-alt或其他软件包管理器,但如今它们都不是很常见的)。 If you're using two such package managers, you really, really shouldn't be unless you know what you're doing.
如果您正在使用两个这样的程序包管理器,那么除非您知道自己在做什么,否则就不应该这样做。 I'd disable one entirely (at least take it off your PATH, if not uninstall it).
我会完全禁用一个(如果不卸载,至少要从PATH中删除它)。 You will likely have to rebuild a bunch of stuff after you do so, but it's better than having a bunch of stuff that kind of sometimes works…
这样做之后,您可能必须重建一堆东西,但是总比拥有一堆有时会起作用的东西要好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.