>source

mysql.connector 가져오기다음 오류가 발생했습니다.

import mysql.connector
ModuleNotFoundError: No module named 'mysql'

그러나 다음 명령은 mysql이 설치되었음을 보여줍니까?

(env) bash-4.2$ pip list | grep mysql
mysql (0.0.3)
mysqlclient (2.0.3)
(env) bash-4.2$ conda list mysql
WARNING conda.core.prefix_data:_load_site_packages(272): Problem reading non-conda package record at lib/python3.6/site-packages/pyzmq-17.0.0-py3.6.egg-info/PKG-INFO. Please verify that you still need this, and if so, that this is still installed correctly. Reinstalling this package may help.
WARNING conda.core.prefix_data:_load_site_packages(272): Problem reading non-conda package record at lib/python3.6/site-packages/jupyterlab-2.3.1-py3.9.egg-info/PKG-INFO. Please verify that you still need this, and if so, that this is still installed correctly. Reinstalling this package may help.
WARNING conda.core.prefix_data:_load_site_packages(272): Problem reading non-conda package record at lib/python3.6/site-packages/conda-4.10.3-py3.6.egg-info/PKG-INFO. Please verify that you still need this, and if so, that this is still installed correctly. Reinstalling this package may help.
WARNING conda.core.prefix_data:_load_site_packages(272): Problem reading non-conda package record at lib/python3.6/site-packages/certifi-2021.5.30-py3.6.egg-info/PKG-INFO. Please verify that you still need this, and if so, that this is still installed correctly. Reinstalling this package may help.
# packages in environment at /apps/external/4/anaconda3:
#
# Name                    Version                   Build  Channel
mysql                     5.7.20               h55eaa98_0    https://mycompany.intranet/repository/anaconda-main-proxy

BTW, 왜 pip mysql 버전이 그렇게 낮습니까? (0.0.3)

확실하지 않지만 웹의 문서에 따르면 conda install mysql-connector-python이 필요할 수 있습니다.

merv2021-10-11 04:35:33
  • 답변 # 1

    pip install mysql-connector 또는 .py 파일 이름을 mysql.py 또는 이와 유사한 것으로 만들지 마십시오.

  • 이전 javascript : React의 사전 문제
  • 다음 statistics : 등급을 기준으로 두 제품을 비교하는 방법은 무엇입니까?