【问题标题】:Django project at Heroku cannot install dependencies with pipHeroku 的 Django 项目无法使用 pip 安装依赖项
【发布时间】:2012-03-27 14:30:20
【问题描述】:

我正在尝试在 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

【问题讨论】:

  • 你能把你的 requirements.txt 也发一下吗?
  • @Sam 实际上我在考虑操作系统行结尾。我在 Windows 7 上,如果他们使用一些 posix 操作系统,但他们没有提到这是教程。

标签: python django heroku virtualenv pip


【解决方案1】:

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

【讨论】:

猜你喜欢
  • 2021-05-29
  • 2012-03-09
  • 2016-08-21
  • 2023-04-03
  • 2014-10-16
  • 1970-01-01
  • 2018-09-27
  • 2011-01-20
  • 1970-01-01
相关资源
最近更新 更多