Git push heroku main命令错误,pywin32错误。

huangapple go评论78阅读模式
英文:

Error regarding git push heroku main command, pywin32 error

问题

当我尝试推送我的新项目时,在终端运行git push heroku main时,我遇到了以下错误:

remote:        INFO: pip is looking at multiple versions of pypiwin32 to determine which version is compatible with other requirements. This could take a while.
remote:        ERROR: Ignored the following versions that require a different python version: 1.9.5 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <3.7
remote:        ERROR: Could not find a version that satisfies the requirement pywin32>=223 (from pypiwin32) (from versions: none)
remote:        ERROR: No matching distribution found for pywin32>=223
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed

这是我的requirements.txt文件:

asgiref==3.3.2
astroid==2.4.2
asttokens==2.2.1
...(省略部分)...
tzdata==2023.3
urllib3==1.26.6
wcwidth==0.2.6
whitenoise==5.2.0
wrapt==1.12.1
zipp==3.14.0

而且我在runtime.txt文件中使用python-3.9.16。我该如何解决这个问题?这变得非常烦人,我已经尝试切换版本,但一直都遇到相同的错误。

英文:

When I am trying to push my new project, I have the following errors when I run git push heroku main in my terminal:

remote:        INFO: pip is looking at multiple versions of pypiwin32 to determine which version is compatible with other requirements. This could take a while.
remote:        ERROR: Ignored the following versions that require a different python version: 1.9.5 Requires-Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <3.
7
remote:        ERROR: Could not find a version that satisfies the requirement pywin32>=223 (from pypiwin32) (from versions: none)
remote:        ERROR: No matching distribution found for pywin32>=223
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed

This is my requirements.txt file

asgiref==3.3.2
astroid==2.4.2
asttokens==2.2.1
backcall==0.2.0
beautifulsoup4==4.9.3
bootstrap4==0.1.0
boto==2.49.0
boto3==1.17.101
botocore==1.20.101
cffi==1.14.5
chromelogger==0.4.3
colorama==0.4.4
comm==0.1.2
debugpy==1.6.6
decorator==5.1.1
distro==1.5.0
dj-database-url==2.0.0
Django==3.2
django-bootstrap3==14.2.0
django-bootstrap4==3.0.1
django-braces==1.14.0
django-crispy-forms==1.11.2
django-debug-toolbar==3.2.1
django-developer-panel==0.1.2
django-misaka==0.2.1
django-storages==1.11.1
django-widget-tweaks==1.4.8
executing==1.2.0
google-compute-engine==2.8.13
gunicorn==20.1.0
houdini.py==0.1.0
importlib-metadata==6.0.0
ipykernel==6.21.2
ipython==8.10.0
isort==5.7.0
jedi==0.18.0
jmespath==0.10.0
jsonpickle==2.0.0
jupyter_client==8.0.3
jupyter_core==5.2.0
lazy-object-proxy==1.4.3
matplotlib-inline==0.1.6
mccabe==0.6.1
misaka==2.1.1
nest-asyncio==1.5.6
numpy==1.24.2
ordereddict==1.1
packaging==23.0
pandas==1.5.3
parso==0.8.1
pickleshare==0.7.5
Pillow==8.2.0
platformdirs==3.0.0
prompt-toolkit==3.0.37
psutil==5.9.4
psycopg2==2.9.6
psycopg2-binary==2.9.6
pure-eval==0.2.2
pycparser==2.20
Pygments==2.9.0
pylint==2.6.0
pypiwin32==223
python-dateutil==2.8.1
pytz==2021.1
pywin32==305
pyzmq==25.0.0
s3transfer==0.4.2
six==1.15.0
soupsieve==2.2.1
sqlparse==0.4.1
stack-data==0.6.2
toml==0.10.2
tornado==6.2
traitlets==5.9.0
typing_extensions==4.5.0
tzdata==2023.3
urllib3==1.26.6
wcwidth==0.2.6
whitenoise==5.2.0
wrapt==1.12.1
zipp==3.14.0

And also I am using python-3.9.16 in my runtime.txt file. How can I resolve this? It is getting very annoying, I have tried to switch the versions but I am still getting the same errors over and over again

答案1

得分: 5

问题出在这里,pywin32,您尝试安装的模块,与Heroku不兼容,Heroku是基于Linux的平台。
pywin32是一组用于Windows的Python扩展,因此与Heroku这样的非Windows平台不兼容。

在您的requirements.txt文件中,您指定要安装pypiwin32==223pywin32==305,这在Heroku上是行不通的。

正如这里所指出的,您可以在Python中使用环境标记来有条件地安装基于系统平台的包。

在您的requirements.txt中,您可以通过在这些行的末尾添加;platform_system == "Windows"来指定只应在Windows上安装pywin32pypiwin32。这样,当Heroku(一个Linux系统)读取文件时,它将跳过这些包。

您的requirements.txt文件应如下所示:

...
# 其他依赖项
...
pypiwin32==223; platform_system == "Windows"
pywin32==305; platform_system == "Windows"
...
# 其他依赖项
...

通过这样做,只有在platform_system为"Windows"时才会安装pywin32pypiwin32。当Heroku尝试安装依赖项时,它应该忽略这两个。

在修改requirements.txt文件后,提交更改并再次推送到Heroku:

git add requirements.txt
git commit -m "有条件地安装Windows特定的包"
git push heroku main
英文:

The problem here seems to be that pywin32, the module you are trying to install, is not compatible with Heroku, which is a Linux-based platform.
pywin32 is a set of Python extensions for Windows, and as such, they are not compatible with non-Windows platforms like Heroku.

In your requirements.txt file, you are specifying to install pypiwin32==223 and pywin32==305, which won't work on Heroku.

As noted here, you can use the environment markers in Python to conditionally install packages based on the system platform.

In your requirements.txt, you can specify that pywin32 and pypiwin32 should only be installed on Windows by adding ; platform_system == "Windows" to the end of those lines. This way, when Heroku (a Linux system) reads the file, it will skip these packages.

Your requirements.txt file should look like this:

...
# Other dependencies
...
pypiwin32==223; platform_system == "Windows"
pywin32==305; platform_system == "Windows"
...
# Other dependencies
...

By doing this, pywin32 and pypiwin32 will only be installed if the platform_system is "Windows". When Heroku tries to install the dependencies, it should ignore these two.

After modifying the requirements.txt file, commit the changes and push to Heroku again:

git add requirements.txt
git commit -m "Conditionally install Windows-specific packages"
git push heroku main

huangapple
  • 本文由 发表于 2023年5月22日 03:52:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76301669.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定