简体   繁体   中英

Issues with mysql-connector-python import

I am having a lot of trouble with the mysql-connector-python package. On my work laptop the package works every time without fail. However, on my personal laptop it seems to be completely random when it works. I am running a Jupyter Notebook in VS Code and using Python 3.6.2.

For example,

First I installed the mysql-connector package in the terminal with: pip install mysql-connector-python

Then I import the package with this command: import mysql.connector

Although, when I try to import the package I get this error: ModuleNotFoundError: No module named 'mysql'

If I restart my computer and then run the import it will work but after restarting the Jupyter kernel or selecting a different kernel, it will stop working until I restart my computer again.

I see this is a problem for other people too but can't seem to find the right fix for my issue. Does anybody know what's going on?

" mysql-connector-python " is a Python module package. When we use different Python environments, its storage location is different. Therefore, we need to select the Python kernel containing this module at the upper right of the Jupyter notebook.

Please check the Python environment you used when installing this module in the VSCode terminal, and also use this environment in Jupyter.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM