我正在使用Heroku作为开发服务器。当我尝试将Django应用程序推送到Heroku时,它首先尝试从requirements.txt
文件安装我的软件包。
requests==2.18.3
ssh-import-id==5.5
问题是我与其他一个软件包之间存在依赖关系。在上述软件包中,ssh-import-id
需要已经安装的requests
软件包。因此,当我推送应用程序时,pip无法安装并停止部署。
Collecting requests==2.18.3 (from -r re.txt (line 1))
Using cached https://files.pythonhosted.org/packages/ba/92/c35ed010e8f96781f08dfa6d9a6a19445a175a9304aceedece77cd48b68f/requests-2.18.3-py2.py3-none-any.whl
Collecting ssh-import-id==5.5 (from -r re.txt (line 2))
Using cached https://files.pythonhosted.org/packages/66/cc/0a8662a2d2a781db546944f3820b9a3a1a664a47c000577b7fb4db2dfbf8/ssh-import-id-5.5.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-go0a5mxf/ssh-import-id/setup.py", line 20, in <module>
from ssh_import_id import __version__
File "/tmp/pip-install-go0a5mxf/ssh-import-id/ssh_import_id/__init__.py", line 25, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-go0a5mxf/ssh-import-id/
我需要使用pip一次安装所有列出的软件包。因为默认情况下,Heroku运行,所以pip install -r requirements.txt
。
答案 0 :(得分:4)
此is a bug。
库的setup.py
导入库以获取要包含在setup()
函数调用中的版本...
import os
from setuptools import setup
from ssh_import_id import __version__
...,并且库尝试导入环境中尚不存在的请求。这是ssh_import_id.__init__.py
:
import argparse
import json
import logging
import os
import platform
import requests # <=== here
import stat
import subprocess
import sys
import tempfile
已添加一个修复程序,该修复程序解决了需要导入软件包以获取版本的情况。
import os
from setuptools import setup
import sys
def read_version():
# shove 'version' into the path so we can import it without going through
# ssh_import_id which has deps that wont be available at setup.py time.
# specifically, from 'ssh_import_id import version'
# will fail due to requests not available.
verdir = os.path.abspath(
os.path.join(os.path.dirname(__file__), "ssh_import_id"))
sys.path.insert(0, verdir)
import version
return version.VERSION
...但是该修补程序不在当前的pypi版本5.6中。
您可以通过将requirements.txt更改为以下内容,从源代码而非pypi安装最新的master分支:
-e git+https://git.launchpad.net/ssh-import-id#egg=master