gpt4 book ai didi

python - django.db.utils.OperationalError : (2013, "Lost connection to MySQL server at ' 握手 : reading inital communication packet', 系统错误:0")

转载 作者:行者123 更新时间:2023-11-30 21:29:45 25 4
gpt4 key购买 nike

我正在 django 中开发一个应用程序以将其推送到 Heroku,在尝试将 mysql 中的数据库迁移到 heroku 时,我 pip 安装了 mysql-python,当我尝试运行服务器时,我收到了这个错误:

django.db.utils.OperationalError: (2013, "Lost connection to MySQLserver at 'handshake: reading inital communication packet', systemerror: 0")

(我有我的虚拟环境)。
奇怪的是,即使我已经安装了 python,包也会安装它。
我发现它卸载了 django 和我之前安装的几个模块,甚至是 pip!

我重新安装了模块,但现在当我运行服务器时,出现了上面的错误。
如果我从另一个应用程序目录运行服务器,数据库运行正常。
它可能与我安装在我的目录中的东西有关,并且可能显然被奇怪的包覆盖了吗?

这是我的 pip 卡住结果:

certifi==2019.6.16
dj-database-url==0.5.0
Django==2.2.3
django-heroku==0.3.1
gunicorn==19.9.0
mysql-connector-python==8.0.16
mysqlclient==1.4.2.post1
protobuf==3.6.0
psycopg2==2.8.3
PyMySQL==0.9.3
python-decouple==3.1
pytz==2019.1
six==1.12.0
sqlparse==0.3.0
whitenoise==4.1.2
wincertstore==0.2

我现在将删除该项目并尝试重新构建它,据我所知,我试图安装 mysql-python 搞砸了该项目。

Collecting mysql-python   Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip Building wheels for collected packages: mysql-python   Building wheel for mysql-python (setup.py) ... error   ERROR: Complete output from command 'C:\Applicazioni_Tommaso\Anaconda3\envs\met3\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\Tommaso\\AppData\\Local\\Temp\\pip-install-yr8h0ec1\\mysql-python\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Tommaso\AppData\Local\Temp\pip-wheel-ywwxryy8' --python-tag cp37:   ERROR: running bdist_wheel   running build   running build_py  creating build   creating build\lib.win-amd64-3.7   copying
_mysql_exceptions.py -> build\lib.win-amd64-3.7 creating build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\__init__.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\converters.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\connections.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\cursors.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\release.py -> build\lib.win-amd64-3.7\MySQLdb copying MySQLdb\times.py -> build\lib.win-amd64-3.7\MySQLdb creating build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.7\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.7\MySQLdb\constants running build_ext building '_mysql' extension creating build\temp.win-amd64-3.7 creating build\temp.win-amd64-3.7\Release C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1)
-D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -IC:\Applicazioni_Tommaso\Anaconda3\envs\met3\include -IC:\Applicazioni_Tommaso\Anaconda3\envs\met3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\cppwinrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.7\Release\_mysql.obj /Zl _mysql.c
_mysql.c(42): fatal error C1083: Non è possibile aprire il file inclusione: 'config-win.h': No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2 ---------------------------------------- ERROR: Failed building wheel for mysql-python Running setup.py clean for mysql-python Failed to build mysql-python Installing collected packages: mysql-python Running setup.py install for mysql-python ... error
ERROR: Complete output from command 'C:\Applicazioni_Tommaso\Anaconda3\envs\met3\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\Tommaso\\AppData\\Local\\Temp\\pip-install-yr8h0ec1\\mysql-python\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Tommaso\AppData\Local\Temp\pip-record-dwqliwhp\install-record.txt'
--single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
copying _mysql_exceptions.py -> build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.7\MySQLdb
creating build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1)
-D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -IC:\Applicazioni_Tommaso\Anaconda3\envs\met3\include -IC:\Applicazioni_Tommaso\Anaconda3\envs\met3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\cppwinrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.7\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(42): fatal error C1083: Non è possibile aprire il file inclusione: 'config-win.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
---------------------------------------- ERROR: Command "'C:\Applicazioni_Tommaso\Anaconda3\envs\met3\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\Tommaso\\AppData\\Local\\Temp\\pip-install-yr8h0ec1\\mysql-python\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Tommaso\AppData\Local\Temp\pip-record-dwqliwhp\install-record.txt'
--single-version-externally-managed --compile" failed with error code 1 in C:\Users\Tommaso\AppData\Local\Temp\pip-install-yr8h0ec1\mysql-python\

更新

错误的命令,即

pip install mysql-python

已将我的 python 默认路径设置为 2.7 而不是 3.7。

要修复它,我必须(Windows 10):

Cortana > 搜索栏 > 输入“env”> 更改系统的环境变量 > 环境变量 > 选择“路径”> 更改 >

创建并移动到顶部(或简单地移动到顶部)安装 python 3.7 的路径。

保存 > 关闭 anaconda。这使得 pyhton 及其模块再次工作。我不得不重新安装 pip,现在它又可以工作了。但是当我的虚拟环境打开时,我在 mysql 中连接的数据库出现问题。

最佳答案

这可能是防火墙 问题。确保运行 MySQL 的端口对来自运行 AppIP 的入站流量开放。

关于python - django.db.utils.OperationalError : (2013, "Lost connection to MySQL server at ' 握手 : reading inital communication packet', 系统错误:0"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56873213/

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