エラーを解決しますC1083:インクルードファイルを開くことができません:「mysql.h」:pipがmysqlclientをインストールしたときにそのようなファイルまたはディレクトリは報告されません



Solve Error C1083



問題の説明:

システム:win10(64ビット)

Pythonバージョン:3.7.8



MySQL Server 8.0

MySQL Connector C 6.1



pip install -r Requirements.txtコマンドを使用すると、mysqlclientへのインストール時にエラーが報告されます(mysqlclientはpipコマンドを介してインストールされています)。

エラー:コマンドが終了ステータス1でエラーになりました:
コマンド: 'c: python3.7.8 python.exe' -u -c'import sys、setuptools、tokenize sys.argv [0] = '' '' 'C:\ Users \ ADMINI〜1 \ AppData \ Local \ Temp \ pip-install-k4s1hfze \ mysqlclient \ setup.py '' '' '__ file __ =' '' '' C:\ Users \ ADMINI〜1 \ AppData \ Local Temp \ pip-install-k4s1hfze \ mysqlclient \ 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 ADMINI〜1 AppData Local Temp pip-record-8r_vb76d install-record.txt '-single-version-externally-マネージド--compile--install-headers'c: python3.7.8 Include mysqlclient '
cwd:C: Users ADMINI〜1 AppData Local Temp pip-install-k4s1hfze mysqlclient
完全な出力(30行):
インストールの実行
実行中のビルド
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 compat.py-> build lib.win-amd64-3.7 MySQLdbをコピーします
MySQLdb connections.py-> build lib.win-amd64-3.7 MySQLdbをコピーします
MySQLdb converters.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 CLIENT.py-> build lib.win-amd64-3.7 MySQLdb constantsをコピーします
MySQLdb constants CR.py-> build lib.win-amd64-3.7 MySQLdb constantsをコピーします
MySQLdb constants ER.py-> build lib.win-amd64-3.7 MySQLdb constantsをコピーします
MySQLdb constants FIELD_TYPE.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をコピーします
build_extを実行しています
'_mysql'拡張機能の構築
build temp.win-amd64-3.7の作成
build temp.win-amd64-3.7 Releaseを作成しています
C: Program Files(x86) Microsoft Visual Studio 14.0 VC BIN x86_amd64 cl.exe / c / nologo / Ox / W3 / GL / DNDEBUG / MD -Dversion_info =(1,3,12、 'final' 、0)-D__version __ = 1.3.12'-IC: Program Files(x86) MySQL MySQL Connector C 6.1 include '-Ic: python3.7.8 include -Ic: python3.7.8 include'-IC : Program Files(x86) Microsoft Visual Studio 14.0 VC 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 '/Tc_mysql.c /Fobuild emp.win-amd64-3.7Release\_mysql.obj / Zl
_mysql.c
_mysql.c(29):致命的なエラーC1083:インクルードファイルを開くことができません: 'mysql.h':そのようなファイルまたはディレクトリはありません
エラー:コマンド 'C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ VC \ BIN \ x86_amd64 \ cl.exe'が終了ステータス2で失敗しました
----------------------------------------
mysqlclientのアンインストールのロールバック
c: python3.7.8 lib site-packages mysqlclient-1.4.6.dist-info に移動します
c: python3.7.8 lib site-packages 〜ysqlclient-1.4.6.dist-infoから
c: python3.7.8 lib site-packages mysqldb に移動します
c: python3.7.8 lib site-packages 〜ysqldbから
エラー:コマンドが終了ステータス1でエラーになりました: 'c: python3.7.8 python.exe' -u -c'import sys、setuptools、tokenize sys.argv [0] = '' '' 'C:\ Users \ ADMINI〜1 \ AppData \ Local \ Temp \ pip-install-k4s1hfze \ mysqlclient \ setup.py '' '' '__ file __ =' '' '' C:\ Users \ ADMINI〜 1 \ AppData \ Local \ Temp \ pip-install-k4s1hfze \ mysqlclient \ 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 ADMINI〜1 AppData Local Temp pip-record-8r_vb76d install-record.txt ' --single-version-externally-managed --compile --install-headers'c: python3.7.8 Include mysqlclient '完全なコマンド出力についてログを確認します。

エラーのスクリーンショットは次のとおりです。



理由分析:

64ビットWindowsの場合、pipがmysqlclientをインストールすると、Program files(x86)フォルダー内の特定のMySQLファイル(「mysql.h」など)のみが検索され、Programファイルは検索されません。このマシンはMySQLコネクタをインストールしますC: Program Files MySQLに移動しますが、C: Program Files(x86)にMySQLインストールディレクトリがないため、プログラムファイル(x86)にコンテンツが見つからないため、エラーが発生します。

解決:

C: Program Files MySQL MySQL Connector C 6.1フォルダーをC: Program Files(x86) MySQL MySQL Connector C 6.1ディレクトリにコピーします(MySQLフォルダー全体をコピーするために非常に単純で失礼な方法を使用しました)。コマンドpipinstall -rrequirements.txtを再実行します。コマンドが正常に実行されました

E:HttpRunnerManager>pip install -r requirements.txt Requirement already satisfied: Django==2.0.3 in c:python3.7.8libsite-packages (from -r requirements.txt (line 1)) (2.0.3) Requirement already satisfied: PyYAML==3.12 in c:python3.7.8libsite-packages (from -r requirements.txt (line 2)) (3.12) Requirement already satisfied: requests==2.18.4 in c:python3.7.8libsite-packages (from -r requirements.txt (line 3)) (2.18.4) Requirement already satisfied: eventlet==0.22.1 in c:python3.7.8libsite-packages (from -r requirements.txt (line 4)) (0.22.1) Collecting mysqlclient==1.3.12 Using cached mysqlclient-1.3.12.tar.gz (89 kB) Collecting django-celery==3.2.2 Using cached django-celery-3.2.2.tar.gz (90 kB) Collecting flower==0.9.2 Using cached flower-0.9.2.tar.gz (1.3 MB) Collecting dwebsocket==0.4.2 Using cached dwebsocket-0.4.2.tar.gz (14 kB) Collecting paramiko==2.4.1 Using cached paramiko-2.4.1-py2.py3-none-any.whl (194 kB) Collecting HttpRunner==1.5.8 Using cached HttpRunner-1.5.8-py2.py3-none-any.whl (48 kB) Requirement already satisfied: pytz in c:python3.7.8libsite-packages (from Django==2.0.3->-r requirements.txt (line 1)) (2020.1) Requirement already satisfied: chardet=3.0.2 in c:python3.7.8libsite-packages (from requests==2.18.4->-r requirements.txt (line 3)) (3.0.4) Requirement already satisfied: certifi>=2017.4.17 in c:python3.7.8libsite-packages (from requests==2.18.4->-r requirements.txt (line 3)) (2020.6.20) Requirement already satisfied: idna=2.5 in c:python3.7.8libsite-packages (from requests==2.18.4->-r requirements.txt (line 3)) (2.6) Requirement already satisfied: urllib3=1.21.1 in c:python3.7.8libsite-packages (from requests==2.18.4->-r requirements.txt (line 3)) (1.22) Requirement already satisfied: greenlet>=0.3 in c:python3.7.8libsite-packages (from eventlet==0.22.1->-r requirements.txt (line 4)) (0.4.16) Requirement already satisfied: celery=3.1.15 in c:usersadministratorappdata oamingpythonpython37site-packages (from django-celery==3.2.2->-r requirements.txt (line 6)) (3.1.26.post2) Collecting tornado>=4.2.0 Using cached tornado-6.0.4-cp37-cp37m-win_amd64.whl (417 kB) Collecting babel>=1.0 Using cached Babel-2.8.0-py2.py3-none-any.whl (8.6 MB) Requirement already satisfied: setuptools in c:python3.7.8libsite-packages (from dwebsocket==0.4.2->-r requirements.txt (line 8)) (47.1.0) Requirement already satisfied: six in c:python3.7.8libsite-packages (from dwebsocket==0.4.2->-r requirements.txt (line 8)) (1.15.0) Collecting cryptography>=1.5 Using cached cryptography-3.1-cp37-cp37m-win_amd64.whl (1.5 MB) Collecting pynacl>=1.0.1 Using cached PyNaCl-1.4.0-cp37-cp37m-win_amd64.whl (206 kB) Collecting pyasn1>=0.1.7 Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB) Collecting bcrypt>=3.1.3 Using cached bcrypt-3.2.0-cp36-abi3-win_amd64.whl (28 kB) Requirement already satisfied: har2case in c:python3.7.8libsite-packages (from HttpRunner==1.5.8->-r requirements.txt (line 10)) (0.3.1) Collecting requests-toolbelt Using cached requests_toolbelt-0.9.1-py2.py3-none-any.whl (54 kB) Requirement already satisfied: Jinja2 in c:python3.7.8libsite-packages (from HttpRunner==1.5.8->-r requirements.txt (line 10)) (2.11.2) Requirement already satisfied: colorama in c:python3.7.8libsite-packages (from HttpRunner==1.5.8->-r requirements.txt (line 10)) (0.4.3) Collecting colorlog Using cached colorlog-4.2.1-py2.py3-none-any.whl (14 kB) Requirement already satisfied: billiard=3.3.0.23 in c:usersadministratorappdata oamingpythonpython37site-packages (from celery=3.1.15->django-celery==3.2.2->-r requirements.txt (line 6)) (3.3.0.23) Requirement already satisfied: kombu=3.0.37 in c:usersadministratorappdata oamingpythonpython37site-packages (from celery=3.1.15->django-celery==3.2.2->-r requirements.txt (line 6)) (3.0.37) Requirement already satisfied: cffi!=1.11.3,>=1.8 in c:python3.7.8libsite-packages (from cryptography>=1.5->paramiko==2.4.1->-r requirements.txt (line 9)) (1.14.2) Requirement already satisfied: MarkupSafe>=0.23 in c:python3.7.8libsite-packages (from Jinja2->HttpRunner==1.5.8->-r requirements.txt (line 10)) (1.1.1) Requirement already satisfied: anyjson>=0.3.3 in c:usersadministratorappdata oamingpythonpython37site-packages (from kombu=3.0.37->celery=3.1.15->django-celery==3.2.2->-r requirements.txt (line 6)) (0.3.3) Requirement already satisfied: amqp=1.4.9 in c:usersadministratorappdata oamingpythonpython37site-packages (from kombu=3.0.37->celery=3.1.15->django-celery==3.2.2->-r requirements.txt (line 6)) (1.4.9) Requirement already satisfied: pycparser in c:python3.7.8libsite-packages (from cffi!=1.11.3,>=1.8->cryptography>=1.5->paramiko==2.4.1->-r requirements.txt (line 9)) (2.20) Using legacy 'setup.py install' for mysqlclient, since package 'wheel' is not installed. Using legacy 'setup.py install' for django-celery, since package 'wheel' is not installed. Using legacy 'setup.py install' for flower, since package 'wheel' is not installed. Using legacy 'setup.py install' for dwebsocket, since package 'wheel' is not installed. Installing collected packages: mysqlclient, django-celery, tornado, babel, flower, dwebsocket, cryptography, pynacl, pyasn1, bcrypt, paramiko, requests-toolbelt, colorlog, HttpRunner Attempting uninstall: mysqlclient Found existing installation: mysqlclient 1.4.6 Uninstalling mysqlclient-1.4.6: Successfully uninstalled mysqlclient-1.4.6 Running setup.py install for mysqlclient ... done Attempting uninstall: django-celery Found existing installation: django-celery 3.3.1 Uninstalling django-celery-3.3.1: Successfully uninstalled django-celery-3.3.1 Running setup.py install for django-celery ... done Running setup.py install for flower ... done Running setup.py install for dwebsocket ... done Attempting uninstall: HttpRunner Found existing installation: httprunner 3.1.4 Uninstalling httprunner-3.1.4: Successfully uninstalled httprunner-3.1.4 Successfully installed HttpRunner-1.5.8 babel-2.8.0 bcrypt-3.2.0 colorlog-4.2.1 cryptography-3.1 django-celery-3.2.2 dwebsocket-0.4.2 flower-0.9.2 mysqlclient-1.3.12 paramiko-2.4.1 pyasn1-0.4.8 pynacl-1.4.0 requests-toolbelt-0.9.1 tornado-6.0.4 E:HttpRunnerManager>

他の理由:

理由1:

1.Mysqlclientのバージョンが一致しません。Mysqlclientのダウンロードアドレス >> import MySQLdb >>>

理由2:

MySQL Connector-cがインストールされていません、ダウンロードアドレス https://downloads.mysql.com/archives/c-c/ 、 ダウンロードとインストール。

理由3:

pip install mysql-connectorコマンドを使用して、mysql-connectorをインストールします

C:UsersAdministrator>pip install mysql-connector Collecting mysql-connector Downloading mysql-connector-2.2.9.tar.gz (11.9 MB) |████████████████████████████████| 11.9 MB 467 kB/s Using legacy 'setup.py install' for mysql-connector, since package 'wheel' is not installed. Installing collected packages: mysql-connector Running setup.py install for mysql-connector ... done Successfully installed mysql-connector-2.2.9

参照:

https://blog.csdn.net/qq_15907907/article/details/88236280

https://www.codenong.com/51294268/