after pip successful installed: ModuleNotFoundError
Question:
I am trying to install the SimPy module so that I can use it in IDLE. However, everytime I try to import in IDLE, I got an error. I already tried reinstalling Python and Pip and tried to modify the location of the apps. SimPy can be found in the directory of Python 2.7. I’m using python 3.6.1.
After I correctly installed simpy in the terminal:
pip install simpy
Requirement already satisfied: simpy in /Library/Python/2.7/site-packages
When I put into IDLE:
Import Simpy
I got the error:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import simpy
ModuleNotFoundError: No module named 'simpy'
How can I solve this?
Answers:
Since you are using python 3.6.1, you may need to specify the type of python you want to install simpy for. Try running pip3 install simpy
to install the simpy module to your python3 library.
I had same problem (on Windows) and the root cause in my case was ANTIVIRUS software! It has “Auto-Containment” feature, that wraps running process with some kind of a virtual machine.
Symptoms are the same: pip install <module>
works fine in one cmd line window and import <module>
fails when executed from another process.
Wherever you’re running your code, try this
import sys
sys.path
sys.executable
It might be possible that you’re running python in one environment and the module is installed in another environment.
What worked for me is that adding the module location to the sys.path
import sys
sys.path.insert(0, r"/path/to/your/module")
When this happened to me (on macOS), the problem turned out to be that the python installation I specified at the top of my script.py was not the same python installation that conda/pip were using on the command line.
To get the command line and my script to match up, I changed the header in my script.py to just use:
#!python
Then when I ran ./script.py
on the command line, everything finally worked.
This command works for me for the same issue.
python -m pip install “your library”
I wrote a package by myself and I thought the __init__.py
could be ignored, then I encountered this issue. when I added an empty __init__.py
to my package, this issue was fixed.
Do not have a file called simpy.py
in the current working directory, as python will try to load this file instead of the module that you want.
This may cause the problem described in the title of this question.
I am trying to install the SimPy module so that I can use it in IDLE. However, everytime I try to import in IDLE, I got an error. I already tried reinstalling Python and Pip and tried to modify the location of the apps. SimPy can be found in the directory of Python 2.7. I’m using python 3.6.1.
After I correctly installed simpy in the terminal:
pip install simpy
Requirement already satisfied: simpy in /Library/Python/2.7/site-packages
When I put into IDLE:
Import Simpy
I got the error:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import simpy
ModuleNotFoundError: No module named 'simpy'
How can I solve this?
Since you are using python 3.6.1, you may need to specify the type of python you want to install simpy for. Try running pip3 install simpy
to install the simpy module to your python3 library.
I had same problem (on Windows) and the root cause in my case was ANTIVIRUS software! It has “Auto-Containment” feature, that wraps running process with some kind of a virtual machine.
Symptoms are the same: pip install <module>
works fine in one cmd line window and import <module>
fails when executed from another process.
Wherever you’re running your code, try this
import sys
sys.path
sys.executable
It might be possible that you’re running python in one environment and the module is installed in another environment.
What worked for me is that adding the module location to the sys.path
import sys
sys.path.insert(0, r"/path/to/your/module")
When this happened to me (on macOS), the problem turned out to be that the python installation I specified at the top of my script.py was not the same python installation that conda/pip were using on the command line.
To get the command line and my script to match up, I changed the header in my script.py to just use:
#!python
Then when I ran ./script.py
on the command line, everything finally worked.
This command works for me for the same issue.
python -m pip install “your library”
I wrote a package by myself and I thought the __init__.py
could be ignored, then I encountered this issue. when I added an empty __init__.py
to my package, this issue was fixed.
Do not have a file called simpy.py
in the current working directory, as python will try to load this file instead of the module that you want.
This may cause the problem described in the title of this question.