可能为python绕过numpy-override.pth吗? [英] Possible to circumvent numpy-override.pth for python?
问题描述
我一直遇到numpy的问题,特别是可以访问从v1.10开始实施的新功能,例如numpy.stack
和numpy.moveaxis
.
I have been running into issues with numpy, specifically having access to newer functionalities like numpy.stack
and numpy.moveaxis
which have been implemented since v1.10.
我使用pip
更新了numpy
,这是我的python软件包管理器. pip install --upgrade numpy
返回:
I have updated numpy
using pip
, which is my go-to package manager for python. pip install --upgrade numpy
returns:
Requirement already up-to-date: numpy in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
当我运行pip freeze | grep numpy
时,我得到:numpy==1.13.3
.但是,如果我尝试在Terminal中运行python:
When I run pip freeze | grep numpy
I get: numpy==1.13.3
. However, if I try to run python in Terminal:
>>> import numpy
>>> numpy.stack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'stack'
>>> numpy.__version__
'1.9.2'
>>> numpy.__file__
'/Library/Python/2.7/site-packages/numpy-override/numpy/__init__.pyc'
很明显,python尝试使用numpy-override.pth
指定的较旧安装.我认为这是在安装Quantum GIS时就位的(我使用kyngchaos安装程序).我想更新此版本的numpy,但我认为这可能会破坏QGIS的依赖关系.因此,我想规避这一点,并使用由pip
安装的numpy
的更新版本.但是,我印象深刻的是numpy-override.pth
否决了所有其他路径设置,并且我需要一种允许QGIS继续工作的解决方案.
Clearly python is trying to use an older install specified by numpy-override.pth
. I think this is was put in place when I installed Quantum GIS (I use kyngchaos installer). I would like to update this version of numpy, but I think that may break dependencies with QGIS. So, I would like to circumvent this and use the updated version of numpy
as installed by pip
. However I am under the impression the numpy-override.pth
overrules all other path settings, and I need a solution that allows QGIS to continue to work.
有什么建议吗?
运行Mac OS X 10.11.6 El Capitan.
Running Mac OS X 10.11.6 El Capitan.
推荐答案
删除numpy-override.pth
.它所做的只是告诉python在哪里找到numpy
.而且,如果它告诉python在错误的位置看,那么它就没有做好工作.默认情况下,python将在site-packages
中查找.但是,pth
会获得第一个dib,并且可以告诉python首先搜索其他地方.由于numpy
确实存在于覆盖目录中,因此python很高兴使用该版本.
Delete numpy-override.pth
. All it does is tell python where to find numpy
. And if it's telling python to look in the wrong place then it's not doing its job. By default python will look in site-packages
. However, the pth
gets first dibs and can tell python to search somewhere else first. Since numpy
does indeed exist in the override directory then python is happy to use that version.
However, this question on the GIS stack exchange states that QGIS expects to find numpy in the location that the pth file states (with the override bit).
这样,您可能希望使用--prefix
选项重新安装numpy并告诉pip
将numpy
放在替代目录中.即.
As such, you may prefer to reinstall numpy with the --prefix
option and tell pip
to put numpy
in the override directory. ie.
pip install numpy --target=/Library/Python/2.7/site-packages/numpy-override
这篇关于可能为python绕过numpy-override.pth吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!