❯ pip install mysqlclient Collecting mysqlclient Using cached mysqlclient-2.1.1.tar.gz (88 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [44 lines of output] mysql_config --version ['8.0.32'] mysql_config --libs ['-L/usr/local/opt/mysql-client/lib', '-lmysqlclient', '-lz', '-L/usr/local/lib', '-lzstd', '-L/usr/local/opt/openssl@1.1/lib', '-lssl', '-lcrypto', '-lresolv'] mysql_config --cflags ['-I/usr/local/opt/mysql-client/include/mysql'] ext_options: library_dirs: ['/usr/local/opt/mysql-client/lib', '/usr/local/lib', '/usr/local/opt/openssl@1.1/lib'] libraries: ['mysqlclient', 'resolv'] extra_compile_args: ['-std=c99'] extra_link_args: [] include_dirs: ['/usr/local/opt/mysql-client/include/mysql'] extra_objects: [] define_macros: [('version_info', "(2,1,1,'final',0)"), ('__version__', '2.1.1')] running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-universal2-cpython-39 creating build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb creating build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.macosx-10.9-universal2-cpython-39 creating build/temp.macosx-10.9-universal2-cpython-39/MySQLdb clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -I/usr/local/opt/mysql-client/include -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/usr/local/opt/mysql-client/include/mysql -I/Users/albert/Site/F8CHAT/env/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-cpython-39/MySQLdb/_mysql.o -std=c99 MySQLdb/_mysql.c:46:10: fatal error: 'Python.h' file not found #include "Python.h" ^~~~~~~~~~ 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. 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: subprocess-exited-with-error × Running setup.py install for mysqlclient did not run successfully. │ exit code: 1 ╰─> [46 lines of output] mysql_config --version ['8.0.32'] mysql_config --libs ['-L/usr/local/opt/mysql-client/lib', '-lmysqlclient', '-lz', '-L/usr/local/lib', '-lzstd', '-L/usr/local/opt/openssl@1.1/lib', '-lssl', '-lcrypto', '-lresolv'] mysql_config --cflags ['-I/usr/local/opt/mysql-client/include/mysql'] ext_options: library_dirs: ['/usr/local/opt/mysql-client/lib', '/usr/local/lib', '/usr/local/opt/openssl@1.1/lib'] libraries: ['mysqlclient', 'resolv'] extra_compile_args: ['-std=c99'] extra_link_args: [] include_dirs: ['/usr/local/opt/mysql-client/include/mysql'] extra_objects: [] define_macros: [('version_info', "(2,1,1,'final',0)"), ('__version__', '2.1.1')] running install /Users/albert/Site/F8CHAT/env/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build/lib.macosx-10.9-universal2-cpython-39 creating build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb creating build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-cpython-39/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.macosx-10.9-universal2-cpython-39 creating build/temp.macosx-10.9-universal2-cpython-39/MySQLdb clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -I/usr/local/opt/mysql-client/include -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/usr/local/opt/mysql-client/include/mysql -I/Users/albert/Site/F8CHAT/env/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-cpython-39/MySQLdb/_mysql.o -std=c99 MySQLdb/_mysql.c:46:10: fatal error: 'Python.h' file not found #include "Python.h" ^~~~~~~~~~ 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> mysqlclient note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. ` ### Environment **MySQL Client** - OS (MacOS Ventura v13.3.1): - Python (Homebrew Python 3.9.6): - Connector/C (Homebrew mysql-client 8.0.18):
如果报错以上内容那么就是你pycharm的环境出问题了 不要用mac自带的python 自己用homebrew下载python3.0 然后重新配置pycharm虚拟环境就可以了