ModuleNotFoundError:没有名为“ mysql.connector”的模块; 'mysql'不是软件包

时间:2020-05-18 03:10:34

标签: python mysql visual-studio-code

我尝试过:

pip install mysql-connector-python

它表示满足要求。

然后我用了:

pip install mysql-connector-python-rf

并收到此错误:

ERROR: Command errored out with exit status 1:
     command: 'c:\users\arush\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\arush\\AppData\\Local\\Temp\\pip-install-komi1sg9\\mysql-connector-python-rf\\setup.py'"'"'; __file__='"'"'C:\\Users\\arush\\AppData\\Local\\Temp\\pip-install-komi1sg9\\mysql-connector-python-rf\\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\arush\AppData\Local\Temp\pip-record-ov8jdz89\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\arush\appdata\local\programs\python\python37\Include\mysql-connector-python-rf'
         cwd: C:\Users\arush\AppData\Local\Temp\pip-install-komi1sg9\mysql-connector-python-rf\    
    Complete output (6 lines):
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\arush\\AppData\\Local\\Temp\\pip-install-komi1sg9\\mysql-connector-nizedpython-rf\\setup.py'"'"'; __file__='"'"'C:\\Users\\arush\\AppData\\Local\\Temp\\pip-install-komi1sg9\\mysql-connector-python-rappdata\local\programs\python\pythonf\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__fiv[0] = '"'"'C:\\Users\\arush\\AppDatle__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.clo\\setup.py'"'"'; __file__='"'"'C:\\Use();exec(compile(code, __file__, '"'"'exec'"'"'))' install --rconnector-python-rf\\setup.py'"'"';fecord 'C:\Users\arush\AppData\Local\Temp\pip-record-ov8jdz89\in).replace('"'"'\r\n'"'"', '"'"'\n'"'stall-record.txt' --single-version-externally-managed --compilestall --record 'C:\Users\arush\AppDa --install-headers 'c:\users\arush\appdata\local\programs\pythoversion-externally-managed --compilen\python37\Include\mysql-connector-python-rf' Check the logs fon\python37\Include\mysql-connector-pr full command output.

2 个答案:

答案 0 :(得分:0)

您可能正在使用python 3。通过终端安装时,尝试使用pip3而不是pip

答案 1 :(得分:0)

如果不获取一些其他背景信息,很难回答这个问题。例如,您是Windows吗?您的点子更新了吗?您是否从anaconda安装了Python?您是否安装了多个版本的Python?

我本以为“已经满足要求”意味着您将文件安装在某处。

在Anaconda命令提示符下,您可以键入“ conda list”以确切知道您已经安装了什么。 Anaconda还有一个有用的GUI,可以准确列出其中的内容