-2

I want to connect django to mysql. So I tried pip install mysqlclient, but I get the following error.

[running environment] machin: M1 Mac OS ventura mysql8.0.30: installed by brew

[trying note] installing Cmake : not solve

Please let me know the latest solution for M1 Mac.

[erro logs]

$ 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
  ╰─> [41 lines of output]
      mysql_config --version
      ['8.0.30']
      mysql_config --libs
      ['-L/opt/homebrew/Cellar/mysql/8.0.30/lib', '-lmysqlclient', '-lz', '-L/opt/homebrew/lib', '-lzstd', '-L/opt/homebrew/opt/openssl@1.1/lib', '-lssl', '-lcrypto', '-lresolv']
      mysql_config --cflags
      ['-I/opt/homebrew/Cellar/mysql/8.0.30/include/mysql']
      ext_options:
        library_dirs: ['/opt/homebrew/Cellar/mysql/8.0.30/lib', '/opt/homebrew/lib', '/opt/homebrew/opt/openssl@1.1/lib']
        libraries: ['mysqlclient', 'resolv']
        extra_compile_args: ['-std=c99']
        extra_link_args: []
        include_dirs: ['/opt/homebrew/Cellar/mysql/8.0.30/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-x86_64-cpython-39
      creating build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      creating build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build/temp.macosx-10.9-x86_64-cpython-39
      creating build/temp.macosx-10.9-x86_64-cpython-39/MySQLdb
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/anaconda3/envs/django/include -arch x86_64 -I/opt/anaconda3/envs/django/include -fPIC -O2 -isystem /opt/anaconda3/envs/django/include -arch x86_64 -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/opt/homebrew/Cellar/mysql/8.0.30/include/mysql -I/opt/anaconda3/envs/django/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-cpython-39/MySQLdb/_mysql.o -std=c99
      xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
      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
  ╰─> [43 lines of output]
      mysql_config --version
      ['8.0.30']
      mysql_config --libs
      ['-L/opt/homebrew/Cellar/mysql/8.0.30/lib', '-lmysqlclient', '-lz', '-L/opt/homebrew/lib', '-lzstd', '-L/opt/homebrew/opt/openssl@1.1/lib', '-lssl', '-lcrypto', '-lresolv']
      mysql_config --cflags
      ['-I/opt/homebrew/Cellar/mysql/8.0.30/include/mysql']
      ext_options:
        library_dirs: ['/opt/homebrew/Cellar/mysql/8.0.30/lib', '/opt/homebrew/lib', '/opt/homebrew/opt/openssl@1.1/lib']
        libraries: ['mysqlclient', 'resolv']
        extra_compile_args: ['-std=c99']
        extra_link_args: []
        include_dirs: ['/opt/homebrew/Cellar/mysql/8.0.30/include/mysql']
        extra_objects: []
        define_macros: [('version_info', "(2,1,1,'final',0)"), ('__version__', '2.1.1')]
      running install
      /opt/anaconda3/envs/django/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-x86_64-cpython-39
      creating build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb
      creating build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-cpython-39/MySQLdb/constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build/temp.macosx-10.9-x86_64-cpython-39
      creating build/temp.macosx-10.9-x86_64-cpython-39/MySQLdb
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/anaconda3/envs/django/include -arch x86_64 -I/opt/anaconda3/envs/django/include -fPIC -O2 -isystem /opt/anaconda3/envs/django/include -arch x86_64 -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/opt/homebrew/Cellar/mysql/8.0.30/include/mysql -I/opt/anaconda3/envs/django/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-cpython-39/MySQLdb/_mysql.o -std=c99
      xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
      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.
apo1948
  • 5
  • 2

1 Answers1

0

Use:

pip install wheel
pip install --upgrade setuptools
  • Thank you your answer. but , I tried above your information though, I couldn't install. I challenge to install Xcode tools. Thank you your Answer. – apo1948 Nov 27 '22 at 12:28