I am developing an app in django to push it on Heroku, and while trying to migrate a database in mysql to heroku, I pip installed mysql-python and as I try to run the server, I got this error: django.db.utils.OperationalError:(2013年,与MySQL的连接断开系统位于握手:读取初始通信数据包"的服务器,系统错误:0) django.db.utils.OperationalError: (2013, "Lost connection to MySQL server at 'handshake: reading inital communication packet', system error: 0")(我启用了虚拟环境).奇怪的是,即使我已经安装了该软件包,该软件包也安装了python.我发现它与django和我先前安装的几个模块(包括pip)完全无关! (I had my virtual environment on).The strange thing is that the package installed python even if I had that already installed. I found out that it unistalled django and several modules I previously installed, even pip!我重新安装了模块,但是现在当我运行服务器时,上面出现了该错误.如果我从另一个应用程序目录运行服务器,则数据库可以正常运行.I re-installed the modules but now as I run the server I get that error above.If I run the server from another app directory, the database runs fine.Is it maybe related to something I had installed in my directory and maybe was apparently overwritten by the strange package?这是我的点冻结结果:certifi==2019.6.16<br>dj-database-url==0.5.0<br>Django==2.2.3<br>django-heroku==0.3.1<br>gunicorn==19.9.0<br>mysql-connector-python==8.0.16<br>mysqlclient==1.4.2.post1<br>protobuf==3.6.0<br>psycopg2==2.8.3<br>PyMySQL==0.9.3<br>python-decouple==3.1<br>pytz==2019.1<br>six==1.12.0<br>sqlparse==0.3.0<br>whitenoise==4.1.2<br>wincertstore==0.2<br>我现在将删除该项目,并尝试重新构建它,只要我了解,搞砸了该项目的就是我尝试安装mysql-python.I will now delete the project and try to rebuild it anew, as long as I understand, what screw up the project was my attempt to install mysql-python.使用缓存收集mysql-python https://files.pythonhosted.org/软件包/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip 用于收集软件包的构建轮:mysql-python构建轮对于mysql-python(setup.py)...错误错误:来自以下位置的完整输出命令'C:\ Applicazioni_Tommaso \ Anaconda3 \ envs \ met3 \ python.exe'-u -c'导入设置工具,tokenize; 文件 =''"'C:\ Users \ Tommaso \ AppData \ Local \ Temp \ pip-install-yr8h0ec1 \ mysql-python \ setup.py'"'; f =getattr(tokenize,'''''open'"',打开)(文件); 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-tagcp37:错误:正在运行bdist_wheel正在运行构建正在运行build_py创建build创建build \ lib.win-amd64-3.7复制_mysql_exceptions.py-> build \ lib.win-amd64-3.7创建build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb__init__.py->build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ converters.py->build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ connections.py->build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ cursors.py->build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ release.py->build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ times.py->build \ lib.win-amd64-3.7 \ MySQLdb创建build \ lib.win-amd64-3.7 \ MySQLdb \ constant复制MySQLdb \ constants__init __.py->build \ lib.win-amd64-3.7 \ MySQLdb \ constant复制MySQLdb \ constants \ CR.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants 复制MySQLdb \ constants \ FIELD_TYPE.py->build \ lib.win-amd64-3.7 \ MySQLdb \ constant复制MySQLdb \ constants \ ER.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants 复制MySQLdb \ constants \ FLAG.py->build \ lib.win-amd64-3.7 \ MySQLdb \ constant复制MySQLdb \ constants \ REFRESH.py->build \ lib.win-amd64-3.7 \ MySQLdb \ constant复制MySQLdb \ constants \ CLIENT.py->build \ lib.win-amd64-3.7 \ MySQLdb \ constant运行build_ext 建立'_mysql'扩展名,建立build \ temp.win-amd64-3.7 创建build \ temp.win-amd64-3.7 \ C:\ Program Files版本(x86)\ Microsoft VisualStudio \ 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 VisualStudio \ 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文件(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):致命错误C1083:可能的非夜间文件包含:'config-win.h':无此类文件或目录错误:命令'C:\ Program Files(x86)\ Microsoft VisualStudio \ 2017 \ BuildTools \ VC \ Tools \ MSVC \ 14.16.27023 \ bin \ HostX86 \ x64 \ cl.exe'失败,退出状态为2 ---------------------------------------- 错误:mysql-python运行setup.py clean的构建轮子失败对于mysql-python无法构建mysql-python安装已收集软件包:mysql-python正在运行setup.py为mysql-python安装...错误错误:命令'C:\ Applicazioni_Tommaso \ Anaconda3 \ envs \ met3 \ python.exe'-u -c'import的完整输出设置工具tokenize; 文件 =''"'C:\ Users \ Tommaso \ AppData \ Local \ Temp \ pip-install-yr8h0ec1 \ mysql-python \ setup.py'"'; f =getattr(tokenize,'''''open'"',打开)(文件); code = f.read().replace('"''\ r \ n'"'',''"'\ n''"'); f.close(); exec(compile(code, file ,''"'exec''"')))'安装-记录'C:\ Users \ Tommaso \ AppData \ Local \ Temp \ pip-record-dwqliwhp \ install-record.txt'-单一版本-外部管理-编译:错误:正在运行安装运行构建运行build_py创建版本创建build \ lib.win-amd64-3.7复制_mysql_exceptions.py-> build \ lib.win-amd64-3.7创建build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb__init__.py-> build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ converters.py-> build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ connections.py-> build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ cursors.py-> build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ release.py-> build \ lib.win-amd64-3.7 \ MySQLdb复制MySQLdb \ times.py-> build \ lib.win-amd64-3.7 \ MySQLdb创建build \ lib.win-amd64-3.7 \ MySQLdb \ constants复制MySQLdb \ constants__init __.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants复制MySQLdb \ constants \ CR.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants复制MySQLdb \ constants \ FIELD_TYPE.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants复制MySQLdb \ constants \ ER.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants复制MySQLdb \ constants \ FLAG.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants复制MySQLdb \ constants \ REFRESH.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants复制MySQLdb \ constants \ CLIENT.py-> build \ lib.win-amd64-3.7 \ MySQLdb \ constants运行build_ext建立'_mysql'扩展创建build \ temp.win-amd64-3.7创建build \ temp.win-amd64-3.7 \ ReleaseC:\ 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 VisualStudio \ 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文件(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):致命错误C1083:可能的非夜间文件包含:'config-win.h':没有此类文件或目录错误:命令'C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ BuildTools \ VC \ Tools \ MSVC \ 14.16.27023 \ bin \ HostX86 \ x64 \ cl.exe'失败,退出状态为2----------------------------------------错误:命令'C:\ Applicazioni_Tommaso \Anaconda3 \ envs \ met3 \ python.exe'-u -c'导入设置工具,tokenize; 文件 =''"'C:\ Users \ Tommaso \ AppData \ Local \ Temp \ pip-install-yr8h0ec1 \ mysql-python \ setup.py''"'; f =getattr(tokenize,'''''open'"',打开)(文件); code = f.read().replace('"''\ r \ n'"'',''"'\ n''"'); f.close(); exec(compile(code, file ,''"'exec''"')))'安装-记录'C:\ Users \ Tommaso \ AppData \ Local \ Temp \ pip-record-dwqliwhp \ install-record.txt'--single-version-externally-managed --compile失败,错误代码为1C:\ Users \ Tommaso \ AppData \ Local \ Temp \ pip-install-yr8h0ec1 \ 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\推荐答案已解决修复了我在上一个答案,我发现,即使与附加的ClearDB连接,Heroku在管理mysql数据库方面也存在一些问题.因此,我在Postgresql中重建了数据库,因此不再需要mysql python模块.这使我不再迷恋Django和Heroku之间的先前冲突.After fixing thing as I decribed in the previous answer ,I found out that Heroku has some problems to manage mysql database, even if connected with the add-on ClearDB.So I rebuilt the database in Postgresql, thus not needing the mysql python modules anymore.This made me not stumble anymore in the previous conflicts between Django and Heroku. 这篇关于django.db.utils.OperationalError:(2013年,“握手时未与MySQL服务器建立连接:读取初始通信数据包",系统错误:"0")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 22:26