mayna
mayna

Reputation: 3

ModuleNotFoundError: No module named 'serial' after pip install pyserial

When trying to run a .py file from a command prompt I am getting the error,

File "C:\Users\mayna\Anaconda3\lib\site-packages\lucidIo\Com.py", line 7, in import serial ModuleNotFoundError: No module named 'serial'

This is even after I have installed the pyserial module using

pip install pyserial

The following line, pip list modules shows that pyserial 3.4 is in fact installed yet for some reason when I try to import serial in a command prompt it gives me the module not found error. The thing that is really throwing me off is that when I directly open a python window and try accessing serial I get this,

>>> import serial     
>>> serial  
<module 'serial' from 'C:\\Users\\mayna\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\serial\\__init__.py'>   

I am not sure where to go from here, I am new to python but from what I have already researched I should not be getting this error anymore. I am running python 3.7 on a windows 10 pc.

Any help would be greatly appreciated. Thank you.

Upvotes: 0

Views: 24444

Answers (1)

Amit Amola
Amit Amola

Reputation: 2510

(Removing comments and adding it as an answer)

Since you have anaconda installed, try this:

conda install pyserial
or
conda install -c conda-forge pyserial

The main reason for this issue would be, that your pip is installing this module in a separate location or to the python's other version in your machine. And you are running Python, maybe on Jupyter or some other IDE which runs via Anaconda. So using above conda install, will install all the dependencies in the required continuum folder from where conda IDEs intake the modules. No, you don't need to uninstall anything mayna, just run the above command in cmd and it should work.

Upvotes: 2

Related Questions