after pip successful installed: ModuleNotFoundError

后端 未结 5 1739
孤街浪徒
孤街浪徒 2021-01-07 23:36

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

相关标签:
5条回答
  • 2021-01-08 00:23

    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.

    0 讨论(0)
  • 2021-01-08 00:28

    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.

    0 讨论(0)
  • 2021-01-08 00:29

    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.

    0 讨论(0)
  • 2021-01-08 00:35

    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.

    0 讨论(0)
  • 2021-01-08 00:39

    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")
    
    0 讨论(0)
提交回复
热议问题