Heroku的Django项目无法使用pip安装依赖项

时间:2012-03-10 11:07:45

标签: python django heroku virtualenv pip

我正在尝试在Heroku上部署django项目。我使用virtualenv和pip来管理依赖项。 virtualenv版本是1.7.1,pip随附它是1.1。我试图强制使用--no-site-packages,但它提示它现在是默认行为。此外,我确信我在虚拟环境中安装了所有内容。 django项目是空的。我按照here的说明进行操作。也许问题是他们的pip和virtualenv版本更老?有谁遇到过这个问题?提前谢谢。

ψ pip.exe freeze
Django==1.3.1
distribute==0.6.24
versiontools==1.8.3
(venv)

ψ more .\requirements.txt
Django==1.3.1
distribute==0.6.24
versiontools==1.8.3

(venv)

ψ git push heroku master
Enter passphrase for key '/c/Program Files (x86)/Vim/.ssh/id_rsa':
Counting objects: 12, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (12/12), 3.30 KiB, done.
Total 12 (delta 2), reused 0 (delta 0)

-----> Heroku receiving push
-----> Python/Django app detected
-----> Preparing virtualenv version 1.7
       New python executable in ./bin/python
       Installing distribute.............................................................................................................................................................................................done.
       Installing pip...............done.
-----> Activating virtualenv
-----> Installing dependencies using pip version 1.0.2
       Exception:
       Traceback (most recent call last):
         File "/tmp/build_k6zl66ydgqxp/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/basecommand.py", line 126, in main
           self.run(options, args)
         File "/tmp/build_k6zl66ydgqxp/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/commands/install.py", line 200, in run
           for req in parse_requirements(filename, finder=finder, options=options):
         File "/tmp/build_k6zl66ydgqxp/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 1255, in parse_requirements
           req = InstallRequirement.from_line(line, comes_from)
         File "/tmp/build_k6zl66ydgqxp/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 82, in from_line
           elif os.path.isdir(path) and (os.path.sep in name or name.startswith('.')):
         File "/tmp/build_k6zl66ydgqxp/lib/python2.7/genericpath.py", line 41, in isdir
           st = os.stat(s)
       TypeError: must be encoded string without NULL bytes, not str

       Storing complete log in /app/.pip/pip.log
 !     Heroku push rejected, failed to compile Python/django app

1 个答案:

答案 0 :(得分:7)

似乎问题出现在requirements.txt中,我是使用powershell和“pip.exe freeze> requirements.txt”命令创建的, 它创建一个名称中包含nullbytes的文件。 我能够通过从github上的示例项目下载requirements.txt并修改它来解决这个问题。 这完成了工作,一切都很好。