我有一个在ubuntu 16.04和python 3.6上工作的项目,但现在我们正试图让它在ubuntu 20.04上运行相同的python版本。我需要在venv上安装所有需求,显然只有mysqlclient==1.3.12失败。
我看了很多关于stackoverflow的文章,但是似乎没有一篇能解决这个问题。
pip3 install mysqlclient==1.3.12错误
Collecting mysqlclient==1.3.12
Using cached mysqlclient-1.3.12.tar.gz (89 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /data/ci-dashboard/CI_Dashboard/ci_env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g3k3l9km/mysqlclient_82099315cb17439080ee5421b4adf991/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g3k3l9km/mysqlclient_82099315cb17439080ee5421b4adf991/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-lpym4ape
cwd: /tmp/pip-install-g3k3l9km/mysqlclient_82099315cb17439080ee5421b4adf991/
Complete output (32 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.6
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.6-8I2qjE/python3.6-3.6.15=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/include/mysql -I/data/ci-dashboard/CI_Dashboard/ci_env/include -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
_mysql.c: In function ‘_mysql_ConnectionObject_ping’:
_mysql.c:1894:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
1894 | my_bool recon = reconnect;
| ^~~~~~~
| bool
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /data/ci-dashboard/CI_Dashboard/ci_env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g3k3l9km/mysqlclient_82099315cb17439080ee5421b4adf991/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g3k3l9km/mysqlclient_82099315cb17439080ee5421b4adf991/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-47odftw8/install-record.txt --single-version-externally-managed --compile --install-headers /data/ci-dashboard/CI_Dashboard/ci_env/include/site/python3.6/mysqlclient
cwd: /tmp/pip-install-g3k3l9km/mysqlclient_82099315cb17439080ee5421b4adf991/
Complete output (32 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.6
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.6-8I2qjE/python3.6-3.6.15=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/include/mysql -I/data/ci-dashboard/CI_Dashboard/ci_env/include -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
_mysql.c: In function ‘_mysql_ConnectionObject_ping’:
_mysql.c:1894:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
1894 | my_bool recon = reconnect;
| ^~~~~~~
| bool
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /data/ci-dashboard/CI_Dashboard/ci_env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g3k3l9km/mysqlclient_82099315cb17439080ee5421b4adf991/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g3k3l9km/mysqlclient_82099315cb17439080ee5421b4adf991/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-47odftw8/install-record.txt --single-version-externally-managed --compile --install-headers /data/ci-dashboard/CI_Dashboard/ci_env/include/site/python3.6/mysqlclient Check the logs for full command output.
我的虚拟环境已经安装了这些库:pip3.6冻结
aiomysql==0.0.20
alembic==1.1.0
appnope==0.1.2
APScheduler==3.5.3
asn1crypto==0.24.0
astroid==2.4.2
autopep8==1.5.4
backcall==0.2.0
bcrypt==3.1.4
beautifulsoup4==4.6.3
cachetools==4.1.1
certifi==2018.8.24
cffi==1.11.5
chardet==3.0.4
click==6.7
colorama==0.4.3
colorhash==1.0.2
configparser==3.7.1
confluent-kafka==1.2.0
cryptography==2.3.1
cssselect==1.0.3
decorator==4.4.2
dill==0.3.1.1
dominate==2.3.1
Flask==1.0.2
Flask-APScheduler==1.10.1
Flask-Bootstrap==3.3.7.1
Flask-HTTPAuth==4.1.0
flask-ldap3-login==0.9.16
Flask-Login==0.4.1
Flask-Migrate==2.5.2
Flask-Minify==0.18
Flask-MonitoringDashboard==3.1.0
Flask-MySQLdb==0.2.0
flask-profiler==1.8.1
flask-sqlacodegen==1.1.8
Flask-SQLAlchemy==2.3.2
Flask-SSLify==0.1.5
Flask-WTF==0.14.2
gevent==1.4.0
greenlet==0.4.15
gunicorn==19.9.0
htmlmin==0.1.12
idna==2.7
inflect==2.1.0
ipykernel==5.3.4
ipython==7.16.1
ipython-genutils==0.2.0
isort==5.4.2
itsdangerous==0.24
jedi==0.17.2
Jinja2==2.11.1
jsmin==2.2.2
jupyter-client==6.1.7
jupyter-core==4.6.3
kafka-python==1.4.7
kazoo==2.5.0
lazy-object-proxy==1.4.3
ldap3==2.5.2
lesscpy==0.14.0
lxml==4.2.5
Mako==1.1.0
MarkupSafe==1.0
mccabe==0.6.1
multi-key-dict==2.0.3
nest-asyncio==1.4.1
numpy==1.18.1
pandas==0.25.3
paramiko==2.4.2
parso==0.7.1
pbr==4.3.0
pexpect==4.8.0
pickleshare==0.7.5
ply==3.11
prompt-toolkit==3.0.7
psutil==5.7.2
ptyprocess==0.6.0
pyasn1==0.4.4
pyasn1-modules==0.2.4
pyclean==2.0.0
pycodestyle==2.6.0
pycparser==2.19
Pygments==2.7.1
pykafka==2.8.0
PyMySQL==0.9.2
PyNaCl==1.3.0
pyOpenSSL==19.0.0
pyquery==1.4.0
python-dateutil==2.7.3
python-editor==1.0.4
python-jenkins==1.2.1
pytz==2018.5
pyzmq==19.0.2
requests==2.19.1
scipy==1.5.2
simplejson==3.17.2
six==1.15.0
SQLAlchemy==1.2.7
tabulate==0.8.5
toml==0.10.1
tornado==6.0.4
traitlets==4.3.3
typed-ast==1.4.1
tzlocal==1.5.1
urllib3==1.23
visitor==0.1.3
wcwidth==0.2.5
Werkzeug==0.14.1
wrapt==1.12.1
WTForms==2.1
xxhash==1.4.3
您使用的是旧的mysqlclient
1.3.12和新的MySQL 8。要么你需要将MySQL降级到5.6版本。或者您需要使用稍后的mysqlclient
。
在2017年12月21日提交a2ebbd2
时修复了不兼容性,因此您需要mysqlclient
的更高版本。
mysqlclient
1.3.13已于2018年6月27日发布。试试它或任何更新的版本。