Python - 让 pip 只在本地搜索额外的包
Python - Let pip only search locally for extra packages
我正在尝试构建一个 NSIS 可分发包,其中包含多个包。
其中之一是 pyVISA-1.8
,它需要包 enum34
才能工作。
现在,我通常在 nsis 脚本中捆绑包所需的所有轮子,但是当我为 pyVISA
执行此操作时,(即告诉 pip 到 pip install enum34-1.X.X.whl
然后 pip install pyVisa-1.8.tar.gz
我不能 import visa
没有失败(指向 enum34)。(这实际上可能是一个错误)
我发现如果我让 pip 自己找到包,安装就会成功。
然而,这不是一个选项,因为这个发行版应该能够 运行 在离线系统上,所以我 需要 在 nsis 安装程序中拥有所有源代码。
如何告诉 pip 本地缓存 enum34.whl 的位置?
此致
编辑:这是错误:
C:\Users\Administrator>pip list
ecdsa (0.13)
enum (0.4.6)
matplotlib (1.4.3)
numpy (1.9.2)
paramiko (1.15.2)
Pillow (3.1.0)
pip (7.1.2)
pycrypto (2.6.1)
pyparsing (2.0.7)
python-dateutil (2.4.2)
python-nmap (0.6.0)
pytz (2015.4)
requests (2.7.0)
setuptools (18.2)
six (1.10.0)
C:\Users\Administrator>pip install C:\python27\Dependencies\enum34-1.1.6-py2-non
e-any.whl
Processing c:\python27\dependencies\enum34-1.1.6-py2-none-any.whl
Installing collected packages: enum34
Successfully installed enum34-1.1.6
C:\Users\Administrator>pip install C:\python27\Dependencies\PyVISA-1.8.tar.gz
Processing c:\python27\dependencies\pyvisa-1.8.tar.gz
Requirement already satisfied (use --upgrade to upgrade): enum34 in c:\python27\
lib\site-packages (from PyVISA==1.8)
Installing collected packages: PyVISA
Running setup.py install for PyVISA
Successfully installed PyVISA-1.8
C:\Users\Administrator>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import visa
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python27\lib\site-packages\visa.py", line 16, in <module>
from pyvisa import logger, __version__, log_to_screen, constants
File "c:\Python27\lib\site-packages\pyvisa\__init__.py", line 45, in <module>
from .highlevel import ResourceManager
File "c:\Python27\lib\site-packages\pyvisa\highlevel.py", line 22, in <module>
from . import constants
File "c:\Python27\lib\site-packages\pyvisa\constants.py", line 599, in <module
>
class AccessModes(enum.IntEnum):
AttributeError: 'module' object has no attribute 'IntEnum'
>>>
问题是 enum-0.4.6 也被安装在路径中的 enum34 之前:(omn 一个全新的安装,两个包都安装了:)
C:\Users\Administrator>python -c "import enum; print enum.__path__"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute '__path__'
从下面的语句可以看出:
C:\Users\Administrator>python -c "import sys; print sys.path"
['', 'c:\Python27\lib\site-packages\enum-0.4.6-py2.7.egg', ..... ]
enum0.4.6 是要检查的第一个路径,这给我们带来了问题,因为我们想要 enum34。我不知道它们的功能不是相互排斥的。反正;卸载 enum 0.4.6 模块解决了我所有的问题,因为 enum34 被反向移植到 python2.7 并且具有 enum 0.4.6 的所有功能,显然:
C:\Users\Administrator>pip uninstall enum
Uninstalling enum-0.4.6:
c:\python27\lib\site-packages\enum-0.4.6-py2.7.egg
现在我们可以查看模块的路径:
C:\Users\Administrator>python -c "import enum; print enum.__path__"
['c:\Python27\lib\site-packages\enum']
我正在尝试构建一个 NSIS 可分发包,其中包含多个包。
其中之一是 pyVISA-1.8
,它需要包 enum34
才能工作。
现在,我通常在 nsis 脚本中捆绑包所需的所有轮子,但是当我为 pyVISA
执行此操作时,(即告诉 pip 到 pip install enum34-1.X.X.whl
然后 pip install pyVisa-1.8.tar.gz
我不能 import visa
没有失败(指向 enum34)。(这实际上可能是一个错误)
我发现如果我让 pip 自己找到包,安装就会成功。 然而,这不是一个选项,因为这个发行版应该能够 运行 在离线系统上,所以我 需要 在 nsis 安装程序中拥有所有源代码。
如何告诉 pip 本地缓存 enum34.whl 的位置?
此致
编辑:这是错误:
C:\Users\Administrator>pip list
ecdsa (0.13)
enum (0.4.6)
matplotlib (1.4.3)
numpy (1.9.2)
paramiko (1.15.2)
Pillow (3.1.0)
pip (7.1.2)
pycrypto (2.6.1)
pyparsing (2.0.7)
python-dateutil (2.4.2)
python-nmap (0.6.0)
pytz (2015.4)
requests (2.7.0)
setuptools (18.2)
six (1.10.0)
C:\Users\Administrator>pip install C:\python27\Dependencies\enum34-1.1.6-py2-non
e-any.whl
Processing c:\python27\dependencies\enum34-1.1.6-py2-none-any.whl
Installing collected packages: enum34
Successfully installed enum34-1.1.6
C:\Users\Administrator>pip install C:\python27\Dependencies\PyVISA-1.8.tar.gz
Processing c:\python27\dependencies\pyvisa-1.8.tar.gz
Requirement already satisfied (use --upgrade to upgrade): enum34 in c:\python27\
lib\site-packages (from PyVISA==1.8)
Installing collected packages: PyVISA
Running setup.py install for PyVISA
Successfully installed PyVISA-1.8
C:\Users\Administrator>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import visa
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python27\lib\site-packages\visa.py", line 16, in <module>
from pyvisa import logger, __version__, log_to_screen, constants
File "c:\Python27\lib\site-packages\pyvisa\__init__.py", line 45, in <module>
from .highlevel import ResourceManager
File "c:\Python27\lib\site-packages\pyvisa\highlevel.py", line 22, in <module>
from . import constants
File "c:\Python27\lib\site-packages\pyvisa\constants.py", line 599, in <module
>
class AccessModes(enum.IntEnum):
AttributeError: 'module' object has no attribute 'IntEnum'
>>>
问题是 enum-0.4.6 也被安装在路径中的 enum34 之前:(omn 一个全新的安装,两个包都安装了:)
C:\Users\Administrator>python -c "import enum; print enum.__path__"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute '__path__'
从下面的语句可以看出:
C:\Users\Administrator>python -c "import sys; print sys.path"
['', 'c:\Python27\lib\site-packages\enum-0.4.6-py2.7.egg', ..... ]
enum0.4.6 是要检查的第一个路径,这给我们带来了问题,因为我们想要 enum34。我不知道它们的功能不是相互排斥的。反正;卸载 enum 0.4.6 模块解决了我所有的问题,因为 enum34 被反向移植到 python2.7 并且具有 enum 0.4.6 的所有功能,显然:
C:\Users\Administrator>pip uninstall enum
Uninstalling enum-0.4.6:
c:\python27\lib\site-packages\enum-0.4.6-py2.7.egg
现在我们可以查看模块的路径:
C:\Users\Administrator>python -c "import enum; print enum.__path__"
['c:\Python27\lib\site-packages\enum']