after pip successful installed: ModuleNotFoundError

╄→尐↘猪︶ㄣ 提交于 2020-07-18 09:35:10

问题


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?


回答1:


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.




回答2:


Wherever you're running your code, try this

import sys

sys.path
sys.executable

It might be possible you're running python in different environment and the module is installed in different environment.




回答3:


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.



来源:https://stackoverflow.com/questions/44528638/after-pip-successful-installed-modulenotfounderror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!