gpt4 book ai didi

python - 即使正确安装 pip 和 mysql 连接器后,我也无法在 Pycharm 上连接到 MySQL

转载 作者:行者123 更新时间:2023-11-29 16:33:26 25 4
gpt4 key购买 nike

我已经正确安装了 mysql 连接器,命令提示符甚至显示安装成功,但由于某种原因,Pycharm 在安装连接器时显示错误。

enter image description here

enter image description here

enter image description here

编码器从这里开始

    Collecting mysqlconnector
Using cached https://files.pythonhosted.org/packages/e4/7c/957e0c387d4c65df42ba56d5160456b0ff6f83f3cda122e18287605e3711/mysqlconnector-0.1.1.tar.gz
Installing collected packages: mysqlconnector
Running setup.py install for mysqlconnector: started
Running setup.py install for mysqlconnector: finished with status 'error'
Complete output from command "C:\Users\Farhan Hasnat\PycharmProjects\untitled1\venv\Scripts\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\FARHAN~1\\AppData\\Local\\Temp\\pycharm-packaging\\mysqlconnector\\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\FARHAN~1\AppData\Local\Temp\pip-record-hnanue0h\install-record.txt --single-version-externally-managed --compile --install-headers "C:\Users\Farhan Hasnat\PycharmProjects\untitled1\venv\include\site\python3.7\mysqlconnector":
running install
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\FARHAN~1\AppData\Local\Temp\pycharm-packaging\mysqlconnector\setup.py", line 47, in <module>
'mysqlconnector = mysqlconnector.cli:cli',
File "C:\Users\Farhan Hasnat\AppData\Local\Programs\Python\Python37-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\Farhan Hasnat\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\Farhan Hasnat\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\FARHAN~1\AppData\Local\Temp\pycharm-packaging\mysqlconnector\setup.py", line 20, in run
raise Exception("You probably meant to install and run mysql-connector")
Exception: You probably meant to install and run mysql-connector

----------------------------------------

Command ""C:\Users\Farhan Hasnat\PycharmProjects\untitled1\venv\Scripts\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\FARHAN~1\\AppData\\Local\\Temp\\pycharm-packaging\\mysqlconnector\\setup.py';f=getattr**strong text**(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\FARHAN~1\AppData\Local\Temp\pip-record-hnanue0h\install-record.txt --single-version-externally-managed --compile --install-headers "C:\Users\Farhan Hasnat\PycharmProjects\untitled1\venv\include\site\python3.7\mysqlconnector"" failed with error code 1 in C:\Users\FARHAN~1\AppData\Local\Temp\pycharm-packaging\mysqlconnector\
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

最佳答案

“msql-connector-repackaged”应该是“mysql-connector-repackaged”,也尝试在“myDB”变量中传递数据库(数据库必须已经创建):

mydb = mysql.connector.connect(
host="localhost",
user="root",
password="password",
database="name of your database"
)

除此之外,您使用的是哪个版本的 pycharm?据我了解,pycharm ce版不支持使用Oracle、MySQL、SQL等数据库管理系统,您需要专业版才能这样做。

我已经能够在 pycharm 中使用 SQLite 构建数据库,但这是内置于 python 中的。我不知道您使用的数据有多大,但如果数据很小,您可以改用 SQLite。

https://www.jetbrains.com/help/pycharm/relational-databases.html

此外,您还可以尝试其他连接包(注意:PyCharm 的创建者 IntelliJ 最终可能会删除它们,以保留非自由 PyCharm 版本的 mysql 兼容性),例如:mysql-connector、mysql-connector-python 、mysql-connector-dd 和 mysql-connector-rf。

关于python - 即使正确安装 pip 和 mysql 连接器后,我也无法在 Pycharm 上连接到 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53752804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com