Deba
Deba

Reputation: 441

ModuleNotFoundError: No module named 'PyMySQL'

I have successfully installed PyMySQL in my Ubuntu 16.04 OS using pip command:

debarati@debarati-hp:~$ pip install PyMySQL
Collecting PyMySQL
  Downloading PyMySQL-0.8.0-py2.py3-none-any.whl (83kB)
    100% |████████████████████████████████| 92kB 159kB/s 
Installing collected packages: PyMySQL
Successfully installed PyMySQL-0.8.0

Still when I am trying to execute a Python file called view_rows.py , it's giving the following error:

debarati@debarati-hp:~$ python view_rows.py
Traceback (most recent call last):
  File "view_rows.py", line 5, in <module>
    import PyMySQL
ModuleNotFoundError: No module named 'PyMySQL'

But, this does not give any error:

debarati@debarati-hp:~$ import PyMySQL 

This is my Python version:

debarati@debarati-hp:~$ python -V
Python 3.6.3 :: Anaconda custom (64-bit)

Upvotes: 0

Views: 8090

Answers (1)

Allan
Allan

Reputation: 17429

The package name is "PyMySQL"; you use the package name to install it. To use the installed package, you need to use the module name, which may not be the same. In this case, the module is named "pymysql" (all lower-case).

The import should be import pymysql.

https://pymysql.readthedocs.io/en/latest/py-modindex.html

Upvotes: 2

Related Questions