import mysql.connector no go

22 views
Skip to first unread message

John Douglas

unread,
Apr 21, 2023, 3:08:03 PM4/21/23
to spyder
I am new to using Spyder, I find it is so easy to use, a lot of thought has gone into it's design. However I have a problem with the Python installed with Spyder. I am using Python with MySQL. When I run a program with the first line "import mysql.connector" the program fails because it can't find the MySQL/Python connector.
I have a previous installation of Python and the program works perfectly with that Python. I tried reinstalling the MySQL/Python Connector, but that made no difference.
Is there a way to make Spyder use the Python that works, or get Spyder to see the connector?

Rich Lysakowski

unread,
Apr 23, 2023, 9:52:40 PM4/23/23
to spyder
This is not a problem with Spyder.  It is a problem because you are not referencing the connector from within your Python virtual environment correctly.  

Did you install the MySQL connector into the Spyder environment where the interpreter lives?  

From the Spyder iPython Console type the following commands to see what "environment" you are running Python in, and the full path to your Python.exe interpreter file.  

import sys
sys.prefix
sys.executable

Then start a regular Windows console (or "terminal" if you are on Linux or MacOSX) and type 

activate base        #  This will activate your Python "base" environment if you installed Python using Anaconda.
conda list              # This will show all packages installed in your environment. 

or "pip list"

This will show whether your MySQL / Python Connector is available in your environment.

johndou...@gmail.com

unread,
Apr 24, 2023, 12:06:05 AM4/24/23
to spyd...@googlegroups.com

Thank you for your response Rich. I had a newer version of Python on my computer. I found a video on YouTube detailing how to redirect Spyder to the new Python version. This solved the problem I was having. Once again thank you.

 

Kind regards John

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spyderlib/07fbacd1-cb49-4ac2-9c36-f6161f927e19n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages