无法在 mac osx 10.10.2 中升级 python 6 包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29485741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to upgrade python six package in mac osx 10.10.2
提问by Anish
I am trying to install latest version of six python package but I have following issues. Can't get rid of six 1.4.1 in mac OSX 10.10.2
我正在尝试安装最新版本的六个 python 包,但我有以下问题。无法在 mac OSX 10.10.2 中去掉 6 个 1.4.1
sudo pip install six --upgrade
Requirement already up-to-date: six in /Library/Python/2.7/site-packages
Cleaning up...
pip search six
six - Python 2 and 3 compatibility utilities
INSTALLED: 1.9.0 (latest)
python -c "import six; print six.version"
1.4.1
which -a python
/usr/bin/python
which -a pip
/usr/local/bin/pip
What is wrong here? Can't upgrade six!
这里有什么问题?不能升级六!
采纳答案by Masakazu Matsushita
Mac OS X's default python is installed as a framework.
Under the framework directory, there is an 'Extras' directory and six
package is already placed there.
Mac OS X 的默认 python 作为框架安装。在框架目录下,有一个“Extras”目录,six
包已经放在那里了。
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py
According to the description (https://github.com/MacPython/wiki/wiki/Which-Python), /System/Library/Frameworks/Python.framework/Versions/2.7/Extras
is listed before /Library/Python/2.7/site-packages
in module search path.
This means all packages already exists in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras
can't upgrade.
根据描述(https://github.com/MacPython/wiki/wiki/Which-Python),在模块搜索路径/System/Library/Frameworks/Python.framework/Versions/2.7/Extras
之前列出/Library/Python/2.7/site-packages
。这意味着所有已存在的软件包/System/Library/Frameworks/Python.framework/Versions/2.7/Extras
都无法升级。
Maybe you should install python manually and not to use default python.
也许你应该手动安装python而不是使用默认的python。
回答by cel
Your pip
binary belongs to /usr/local/bin/python
, whereas python
points to /usr/bin/python
. As a consequence
您的pip
二进制文件属于/usr/local/bin/python
,而python
指向/usr/bin/python
。作为结果
pip install --upgrade six
will install to /usr/local/bin/python
.
将安装到/usr/local/bin/python
.
The command below will make sure that the right version of pip is used:
下面的命令将确保使用正确版本的 pip:
python -m pip install --upgrade six
回答by matt burns
回答by user1833042
I came across this exact issue when using pip to install the openstack client. My fix was to use easy_install instead of pip, as it utilizes /Library/Python/2.7/site-packages/
for module installation instead of the /System/Library/Frameworks/Python.framework/Versions/2.7/Extras
. If this workaround is not an option for you, then I can confirm that @Masakazu Matsushita has the correct workaround of setting PYTHONPATH
to /Library/Python/2.7/site-packages
. To implement that workaround, add this line:
我在使用 pip 安装 openstack 客户端时遇到了这个确切的问题。我的解决方法是使用 easy_install 而不是 pip,因为它/Library/Python/2.7/site-packages/
用于模块安装而不是/System/Library/Frameworks/Python.framework/Versions/2.7/Extras
. 如果这种解决方法是不适合你的选择,那么我可以证实,@Masakazu松下已设定的正确解决办法PYTHONPATH
来/Library/Python/2.7/site-packages
。要实施该解决方法,请添加以下行:
export PYTHON_PATH=/Library/Python/2.7/site-packages
to your ~/.bashrc
and ~/.profile
(if its a GUI Python application that you are trying to install).
到您的~/.bashrc
和~/.profile
(如果它是您尝试安装的 GUI Python 应用程序)。
回答by varepsilon
While one or another of the above solutions may work for you, I think it's important to understand what is going on and what are the options that you have. I found this(rather lengthy) description to be very useful: it starts with outlining the options and only then suggests solutions.
虽然上述一种或另一种解决方案可能对您有用,但我认为了解正在发生的事情以及您有哪些选择很重要。我发现这个(相当冗长的)描述非常有用:它从概述选项开始,然后才提出解决方案。
回答by Shamshad Alam
Try these steps
试试这些步骤
Reinstall python using brew
$ brew install python
Resolve missing symlink problem
$ brew link --overwrite python
Reboot system or run
$ hash -r python
使用 brew 重新安装 python
$ brew install python
解决缺少符号链接的问题
$ brew link --overwrite python
重启系统或运行
$ hash -r python
回答by kellyxiepei
I resolved the problem by the following method.
我通过以下方法解决了这个问题。
- Download the six-1.10.0.tar.gz package
- Use this command to install it.
- 下载6-1.10.0.tar.gz包
- 使用此命令安装它。
python setup.py install
python setup.py install
This works because it installs the new version of six to /Library/Python/2.7/site-packages/which is searched before /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/
这是有效的,因为它将新版本的 6 安装到/Library/Python/2.7/site-packages/之前搜索/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/
回答by Mika H?m?l?inen
What worked for me was to use easy_install
instead of pip
.
对我有用的是使用easy_install
而不是pip
.
easy_install -U six
Easy_install managed to upgrade the package even when pip failed.
即使 pip 失败,Easy_install 也设法升级了软件包。
回答by trim
In the end, the problem for me was that I was using the IPython shell.
最后,我的问题是我使用的是 IPython shell。
which ipython
returned /usr/local/bin/ipython
and upon inspection this file declared at the top #!/usr/bin/python
, which seemed to be circumventing all my best efforts to use the correct python location.
which ipython
返回/usr/local/bin/ipython
并检查此文件在顶部声明#!/usr/bin/python
,这似乎绕过了我使用正确 python 位置的所有最大努力。
Simply changing this line #!/usr/local/bin/python
to point to the correct python version then meant IPython used the correct six
module.
只需将这一行更改#!/usr/local/bin/python
为指向正确的 python 版本,就意味着 IPython 使用了正确的six
模块。
回答by Harry1992
Try with pip2 its work for me pip2 install -U six
尝试使用 pip2 它对我有用 pip2 install -U 六