PYMYSQL not importing

0 views
Skip to first unread message

Larry Green

unread,
Feb 15, 2015, 5:54:13 PM2/15/15
to anac...@continuum.io
Hi,

Using Anaconda 2.1, python 3.4 64 bit running on Windows 7 64bit.

From Anaconda command, upgraded anaconda with conda install anaconda.

conda list shows pymysql 6.3 installed.

verified that pymysql is in anaconda3/Lib/site-packages/pymysql.

from iPython in Spyder verified with sys.path that the site-packages path is in the path.

from in iPython in Spyder, "import pymysql" returns "ImportError: No module named 'pymysql'".

When I open the __init__.py file that is in the site-packages/PyMySQL directory, I can now import pymysql successfully.

How can I make pymysql import successfully and naturally, and why is this happening? 

Thanks all, this has been killing me... 

Aaron Meurer

unread,
Feb 19, 2015, 12:09:03 PM2/19/15
to anaconda
If you start python in a cmd prompt are you able to import it from there?

Aaron Meurer
> --
> Anaconda Community Support Group Brought to you by Continuum Analytics
> ---
> You received this message because you are subscribed to the Google Groups
> "Anaconda - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to anaconda+u...@continuum.io.
> To post to this group, send email to anac...@continuum.io.
> Visit this group at http://groups.google.com/a/continuum.io/group/anaconda/.

Ilan Schnell

unread,
Feb 19, 2015, 12:10:01 PM2/19/15
to Anaconda
Hi Larry,
what is the output when you type:
>>> import sys
>>> sys.path

Thanks   Ilan


On Sun, Feb 15, 2015 at 4:54 PM, Larry Green <lgr...@smartmarketdata.com> wrote:

Larry Green

unread,
Feb 19, 2015, 1:03:35 PM2/19/15
to anac...@continuum.io

Hi Ilan,

 

['',

'C:\\Anaconda3\\lib\\site-packages\\spyderlib\\utils\\external',

'C:\\Anaconda3\\python34.zip',

'C:\\Anaconda3\\DLLs',

'C:\\Anaconda3\\lib',

'C:\\Anaconda3',

'c:\\anaconda3\\lib\\site-packages\\runipy-0.1.1-py3.4.egg',

'c:\\anaconda3\\lib\\site-packages\\setuptools-12.1-py3.4.egg',

'C:\\Anaconda3\\lib\\site-packages',

'C:\\Anaconda3\\lib\\site-packages\\Sphinx-1.2.3-py3.4.egg',

'C:\\Anaconda3\\lib\\site-packages\\win32',

'C:\\Anaconda3\\lib\\site-packages\\win32\\lib',

'C:\\Anaconda3\\lib\\site-packages\\Pythonwin',

'C:\\Anaconda3\\lib\\site-packages\\IPython\\extensions',

'C:\\Users\\SMD1\\.ipython']

 

As a stop gap, I have been executing à sys.path.append('C:\\Anaconda3\\lib\\site-packages\\PyMySQL'), and this works, but I have to do it everytime I restart Spyder.

 

I just don’t understand why this wouldn’t be automatic, when all of the other modules in that directory are automatically available…

Ilan Schnell

unread,
Feb 19, 2015, 1:10:35 PM2/19/15
to Anaconda
I don't understand how adding C:\\Anaconda3\\lib\\site-packages\\PyMySQL can fix this problem, there is an __init__.py file on site-packages\pymysql, so adding the above path should not be necessary.  Can you check if the __init__.py file is in C:\\Anaconda3\\lib\\site-packages\\pymysql ?

Thanks   Ilan

Larry Green

unread,
Feb 19, 2015, 2:42:12 PM2/19/15
to anac...@continuum.io

Hi, ya it’s in the directory.  Here is a snapshot of the directory.  Really strange, I agree. 

 

Larry Green

unread,
Feb 19, 2015, 2:45:03 PM2/19/15
to anac...@continuum.io

Not there either...

 

 

-----Original Message-----
From: Aaron Meurer [mailto:aaron....@continuum.io]
Sent: Thursday, February 19, 2015 12:09 PM
To: anaconda
Subject: Re: [Anaconda Support] PYMYSQL not importing

 

If you start python in a cmd prompt are you able to import it from there?

clarry...@gmail.com

unread,
Feb 24, 2015, 12:47:50 PM2/24/15
to anac...@continuum.io
No response, 

I think I should assume this is an uninstall anaconda, reboot, reinstall anaconda moment…  ;)

Ryan Nelson

unread,
Feb 25, 2015, 10:00:17 AM2/25/15
to anac...@continuum.io
Larry,

From looking at your screenshot, the PyMySQL folder in your site-packages is not correctly installed. It looks like PyMySQL was downloaded and unzipped directly into site-packages. Try moving that PyMySQL folder out of site-packages, maybe to C:\ and do the following:
C:\> pip install C:\PyMySQL\
Does that install things properly? The site-packages folder should be called "pymysql", and will contain many of the files that you see in the folder of the same name in your screenshot.
However, if you use "conda", you can install this package directly (I tried this on my Win machine and it worked fine):
C:\> conda install pymysql
Hope that helps.

Ryan

Larry Green

unread,
Feb 25, 2015, 10:06:09 AM2/25/15
to anac...@continuum.io
OK, so remove the directory completely, then condo install pymysql?

________________________________

Larry Green, CFA

SmartMarketData, LLC

lgr...@SmartMarketData.com

203.829.3000 (m)


Ryan Nelson

unread,
Feb 25, 2015, 10:14:51 AM2/25/15
to anac...@continuum.io
Larry, 

You don't need to "remove" it, but just move it for the time being. (I don't think windows respects case-sensitive folder names, so keeping that folder there will cause problems.)
Yes. Then use "conda" to install -- not "condo". 

Ryan

himanshus...@gmail.com

unread,
May 7, 2018, 12:41:14 PM5/7/18
to Anaconda - Public, lgr...@smartmarketdata.com
why i am getting error while iporting pymysql in spyder 3.6.plz help
 
Screenshot (43).png

Will Warner

unread,
May 7, 2018, 5:38:32 PM5/7/18
to Anaconda - Public
It looks like pymysql is not installed in the active environment.

Try this:
- Open the Anaconda Prompt.
- If you are using an environment other than "base", then run "conda activate myEnv". Replace "myEnv" with your environment's name.
- Run "conda install pymysql".
- Run "spyder".
- See if "import pymysql" works now.

If that doesn't work, try this:
- Open the Anaconda Prompt.
- If you are using an environment other than "base", then run "conda activate myEnv". Replace "myEnv" with your environment's name.
- Run "conda install pymysql".
- Run "python".
- Run "import pymysql" and see if it displays any errors, or displays a new prompt with no errors.

Please let us know whether either of these work.
Reply all
Reply to author
Forward
0 new messages