将django应用程序部署到Heroku时导入错误

时间:2017-06-01 09:43:01

标签: python django heroku six

我正在尝试部署他们在入门部分中提到的应用。但是我收到错误ModuleNotFoundError: No module named 'six'。整个构建日志如下所述:

-----> Python app detected
-----> Installing python-3.6.1
-----> Installing pip
-----> Installing requirements with pip
       Collecting dj-database-url==0.4.1 (from -r /tmp/build_1900e0c2c9d2dd1135d0cd7b517175ae/requirements.txt (line 1))
         Downloading dj-database-url-0.4.1.tar.gz
       Collecting Django==1.9.7 (from -r /tmp/build_1900e0c2c9d2dd1135d0cd7b517175ae/requirements.txt (line 2))
         Downloading Django-1.9.7-py2.py3-none-any.whl (6.6MB)
       Collecting gunicorn==19.6.0 (from -r /tmp/build_1900e0c2c9d2dd1135d0cd7b517175ae/requirements.txt (line 3))
         Downloading gunicorn-19.6.0-py2.py3-none-any.whl (114kB)
       Collecting psycopg2==2.6.2 (from -r /tmp/build_1900e0c2c9d2dd1135d0cd7b517175ae/requirements.txt (line 4))
         Downloading psycopg2-2.6.2.tar.gz (376kB)
       Collecting whitenoise==2.0.6 (from -r /tmp/build_1900e0c2c9d2dd1135d0cd7b517175ae/requirements.txt (line 5))
         Downloading whitenoise-2.0.6-py2.py3-none-any.whl
       Installing collected packages: dj-database-url, Django, gunicorn, psycopg2, whitenoise
         Running setup.py install for dj-database-url: started
           Running setup.py install for dj-database-url: finished with status 'error'
           Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-vkji1x5w/dj-database-url/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-e09119wj-record/install-record.txt --single-version-externally-managed --compile:
           running install
           running build
           running build_py
           creating build
           creating build/lib
           copying dj_database_url.py -> build/lib
           running egg_info
           writing dj_database_url.egg-info/PKG-INFO
           writing dependency_links to dj_database_url.egg-info/dependency_links.txt
           writing top-level names to dj_database_url.egg-info/top_level.txt
           reading manifest file 'dj_database_url.egg-info/SOURCES.txt'
           writing manifest file 'dj_database_url.egg-info/SOURCES.txt'
           running install_lib
           copying build/lib/dj_database_url.py -> /app/.heroku/python/lib/python3.6/site-packages
           byte-compiling /app/.heroku/python/lib/python3.6/site-packages/dj_database_url.py to dj_database_url.cpython-36.pyc
           running install_egg_info
           Copying dj_database_url.egg-info to /app/.heroku/python/lib/python3.6/site-packages/dj_database_url-0.4.1-py3.6.egg-info
           running install_scripts
           Traceback (most recent call last):
             File "<string>", line 1, in <module>
             File "/tmp/pip-build-vkji1x5w/dj-database-url/setup.py", line 89, in <module>
               'Programming Language :: Python :: 3.5',
             File "/app/.heroku/python/lib/python3.6/distutils/core.py", line 148, in setup
               dist.run_commands()
             File "/app/.heroku/python/lib/python3.6/distutils/dist.py", line 955, in run_commands
               self.run_command(cmd)
             File "/app/.heroku/python/lib/python3.6/distutils/dist.py", line 974, in run_command
               cmd_obj.run()
             File "/app/.heroku/python/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
               return orig.install.run(self)
             File "/app/.heroku/python/lib/python3.6/distutils/command/install.py", line 557, in run
               self.run_command(cmd_name)
             File "/app/.heroku/python/lib/python3.6/distutils/cmd.py", line 313, in run_command
               self.distribution.run_command(command)
             File "/app/.heroku/python/lib/python3.6/distutils/dist.py", line 974, in run_command
               cmd_obj.run()
             File "/app/.heroku/python/lib/python3.6/site-packages/setuptools/command/install_scripts.py", line 17, in run
               import setuptools.command.easy_install as ei
             File "/app/.heroku/python/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 49, in <module>
               from setuptools.py27compat import rmtree_safe
             File "/app/.heroku/python/lib/python3.6/site-packages/setuptools/py27compat.py", line 7, in <module>
               import six
           ModuleNotFoundError: No module named 'six'

           ----------------------------------------
       Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-vkji1x5w/dj-database-url/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-e09119wj-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-vkji1x5w/dj-database-url/
 !     Push rejected, failed to compile Python app.
 !     Push failed

我甚至安装了six模块,但它无效。

1 个答案:

答案 0 :(得分:0)

您(以及其他许多人)正面临this issue

  

使用以下预安装命令将CI environment升级到v36以下:

pip install --upgrade "setuptools < 36"

然后,通过确保您即将创建的virtualenv继承该版本并使用以下环境变量:

VIRTUALENV_NO_DOWNLOAD=1

另一个解决方法是在 运行任何其他命令之前安装模块six

Github回购中的官方回应是,它将尽快修复。 希望它有效。干杯!