gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 20:51:29 24 4
gpt4 key购买 nike

我正在尝试在 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 中,我使用 powershell 和“pip.exe freeze > requirements.txt”命令创建了它,它创建一个名称中包含空字节的文件。我能够通过从 github 上的示例项目下载 requirements.txt 并修改它来解决这个问题。这样就完成了工作,一切都很好。

关于python - Heroku 的 Django 项目无法使用 pip 安装依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9645924/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com