Error regarding git push heroku main command, pywin32 error
Question:
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
Answers:
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
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
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