[英]/app/.heroku/python/lib/python3.7/site-packages/Crypto/PublicKey/RSA.py - Invalid syntax error
I am new to Python and Heroku.我是 Python 和 Heroku 的新手。 When I run the python app in heroku, I am getting below error.当我在 heroku 中运行 python 应用程序时,出现以下错误。 I tried to run the app locally and it works fine.我尝试在本地运行该应用程序,它工作正常。 Can anyone please help me, how to fix this.任何人都可以帮助我,如何解决这个问题。
(myvenv) C:\Users\pc\Desktop\user1\heroku_captsone>heroku run python manage.py db upgrade test-app
» Warning: heroku update available from 7.53.0 to 7.60.2.
Running python manage.py db upgrade test-app on ⬢ test-app... up, run.8455 (Free)
Traceback (most recent call last):
File "manage.py", line 4, in <module>
from app import app
File "/app/app.py", line 12, in <module>
from auth.auth import *
File "/app/auth/auth.py", line 5, in <module>
from jose import jwt
File "/app/.heroku/python/lib/python3.7/site-packages/jose/jwt.py", line 11, in <module>
from jose import jws
File "/app/.heroku/python/lib/python3.7/site-packages/jose/jws.py", line 8, in <module>
from jose import jwk
File "/app/.heroku/python/lib/python3.7/site-packages/jose/jwk.py", line 10, in <module>
from jose.backends.base import Key
File "/app/.heroku/python/lib/python3.7/site-packages/jose/backends/__init__.py", line 3, in <module>
from jose.backends.pycrypto_backend import RSAKey
File "/app/.heroku/python/lib/python3.7/site-packages/jose/backends/pycrypto_backend.py", line 7, in <module>
from Crypto.PublicKey import RSA
File "/app/.heroku/python/lib/python3.7/site-packages/Crypto/PublicKey/RSA.py", line 137
e, d, n, p, q, u = [self._key[comp] for comp in 'e', 'd', 'n', 'p', 'q', 'u']
^
SyntaxError: invalid syntax
Below is the requirements.txt file下面是 requirements.txt 文件
alembic==1.4.2
aniso8601==6.0.0
astroid==2.2.5
autopep8==1.5.2
Babel==2.8.0
Click==7.0
ecdsa==0.13.3
Flask==1.0.2
Flask-Cors==3.0.8
Flask-Migrate==2.7.0
Flask-Moment==0.9.0
Flask-RESTful==0.3.7
Flask-Script==2.0.6
Flask-SQLAlchemy==2.4.0
Flask-WTF==0.14.3
future==0.17.1
gunicorn==20.0.4
isort==4.3.18
itsdangerous==1.1.0
Jinja2==2.10.1
lazy-object-proxy==1.4.0
Mako==1.1.2
MarkupSafe==1.1.1
mccabe==0.6.1
psycopg2==2.8.5
psycopg2-binary==2.9.1
pycodestyle==2.6.0
pycryptodome==3.3.1
pylint==2.3.1
python-dateutil==2.6.0
python-editor==1.0.4
python-jose-cryptodome==1.3.2
pytz==2019.1
six==1.12.0
SQLAlchemy==1.3.3
typed-ast==1.4.2
Werkzeug==0.15.3
wrapt==1.11.1
WTForms==2.3.1
I have set python runtime version 3.7.9 but I tried with 3.8.12 as well but getting same error.我已经设置了 python 运行时版本 3.7.9,但我也尝试了 3.8.12,但得到了同样的错误。
I had a similar problem and, in the process of finding a solution, I discovered that the latest version of python-jose-cryptodome==1.3.2
was released in 2017 and it seems it has not been updated since then.我遇到了类似的问题,在寻找解决方案的过程中,我发现最新版本的python-jose-cryptodome==1.3.2
是在 2017 年发布的,从那以后它似乎就没有更新过。 See this link https://pypi.org/project/python-jose-cryptodome/请参阅此链接https://pypi.org/project/python-jose-cryptodome/
So I uninstalled it and replaced it with the more recent python-jose 3.3.0
which was released in June of 2021. See this link https://pypi.org/project/python-jose/因此,我将其卸载并替换为 2021 年 6 月发布的更新的python-jose 3.3.0
。请参阅此链接https://pypi.org/project/python-jose/
Just run the following lines of code:只需运行以下代码行:
$ pip uninstall python-jose-cryptodome==1.3.2
This will remove the old library. $ pip uninstall python-jose-cryptodome==1.3.2
这将删除旧库。
$ pip install python-jose
This will install the new one $ pip install python-jose
这将安装新的
pip freeze > requirements.txt
This will add the new installation to your requirements.txt file. pip freeze > requirements.txt
这会将新安装添加到您的 requirements.txt 文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.