pip 没有安装依赖项
Dependencies are not installed by pip
我有一个图书馆 setup.py
:
from setuptools import setup
from mylib import __version__
requirements = ['paramiko']
tests_require = ['pytest']
def main():
setup(
name='mypackage',
description='A collection of utilities',
url='http://example.net',
version=__version__,
author='Me Me',
author_email='me@me.net',
packages=['mylib'],
zip_safe=False,
install_requires=requirements,
tests_require=tests_require,
)
if __name__ == '__main__':
main()
我已将此包发布到内部 devpi
服务器。每当我尝试安装它时,我都会得到:
» pip install mypackage
Looking in indexes: http://devpi.mine/myuser/dev/+simple/
Collecting mypackage
Downloading http://devpi.mine/myuser/dev/+f/a8c/c05e3a49de4fe/mypackage-0.0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-ee238ja7/mypackage/setup.py", line 3, in <module>
from mypackage import __version__
File "/tmp/pip-install-ee238ja7/mypackage/mylib/__init__.py", line 3, in <module>
from .storage_host import StoraHostType
File "/tmp/pip-install-ee238ja7/mypackage/mylib/storage_host.py", line 5, in <module>
from .ssh import SSH
File "/tmp/pip-install-ee238ja7/mypackage/mylib/ssh.py", line 5, in <module>
import paramiko
ModuleNotFoundError: No module named 'paramiko'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-ee238ja7/mypackage/
为什么 pip
没有在 setup.py
中安装 install_requires
中列出的要求?
那是因为您在 setup
执行之前引用了您的包裹。
Pip 需要先触摸 setup(...)
才能完成所有操作。但在它之前,你from mylib import __version__
。所以 setup
根本不执行。
我有一个图书馆 setup.py
:
from setuptools import setup
from mylib import __version__
requirements = ['paramiko']
tests_require = ['pytest']
def main():
setup(
name='mypackage',
description='A collection of utilities',
url='http://example.net',
version=__version__,
author='Me Me',
author_email='me@me.net',
packages=['mylib'],
zip_safe=False,
install_requires=requirements,
tests_require=tests_require,
)
if __name__ == '__main__':
main()
我已将此包发布到内部 devpi
服务器。每当我尝试安装它时,我都会得到:
» pip install mypackage
Looking in indexes: http://devpi.mine/myuser/dev/+simple/
Collecting mypackage
Downloading http://devpi.mine/myuser/dev/+f/a8c/c05e3a49de4fe/mypackage-0.0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-ee238ja7/mypackage/setup.py", line 3, in <module>
from mypackage import __version__
File "/tmp/pip-install-ee238ja7/mypackage/mylib/__init__.py", line 3, in <module>
from .storage_host import StoraHostType
File "/tmp/pip-install-ee238ja7/mypackage/mylib/storage_host.py", line 5, in <module>
from .ssh import SSH
File "/tmp/pip-install-ee238ja7/mypackage/mylib/ssh.py", line 5, in <module>
import paramiko
ModuleNotFoundError: No module named 'paramiko'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-ee238ja7/mypackage/
为什么 pip
没有在 setup.py
中安装 install_requires
中列出的要求?
那是因为您在 setup
执行之前引用了您的包裹。
Pip 需要先触摸 setup(...)
才能完成所有操作。但在它之前,你from mylib import __version__
。所以 setup
根本不执行。