PyCharm doesn't recognise installed module

前端 未结 14 2233
闹比i
闹比i 2020-12-03 06:55

I\'m having trouble with using \'requests\' module on my Mac. I use python34 and I installed \'requests\' module via pip. I can verify this via running installation again an

相关标签:
14条回答
  • 2020-12-03 07:29

    After pip installing everything I needed. I went to the interpreter and re-pointed it back to where it was at already. My case: python3.6 in /anaconda3/bin/python using virtualenv...

    Additionally, before I hit the plus "+" sign to install a new package. I had to deselect the conda icon to the right of it. Seems like it would be the opposite, but only then did it recognize the packages I had/needed via query.

    0 讨论(0)
  • 2020-12-03 07:30

    In my case the packages were installed via setup.py + easy_install, and the they ends up in *.egg directories in site_package dir, which can be recognized by python but not pycharm.

    I removed them all then reinstalled with pip install and it works after that, luckily the project I was working on came up with a requirements.txt file, so the command for it was:

    pip install -r ./requirement.txt

    0 讨论(0)
  • 2020-12-03 07:30

    I just ran into this issue in a brand new install/project, but I'm using the Python plugin for IntelliJ IDEA. It's essentially the same as PyCharm but the project settings are a little different. For me, the project was pointing to the right Python virtual environment but not even built-in modules were being recognized.

    It turns out the SDK classpath was empty. I added paths for venv/lib/python3.8 and venv/lib/python3.8/site-packages and the issue was resolved. File->Project Structure and under Platform Settings, click SDKs, select your Python SDK, and make sure the class paths are there.

    0 讨论(0)
  • 2020-12-03 07:35

    Open python console of your pyCharm. Click on Rerun. It will say something like following on the very first line

    /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py 52631 52632
    

    in this scenario pyCharm is using following interpretor

    /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 
    

    Now fire up console and run following command

    sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 -m pip install <name of the package>
    

    This should install your package :)

    0 讨论(0)
  • 2020-12-03 07:35

    On windows I had to cd into the venv folder and then cd into the scripts folder, then pip install module started to work

    cd venv
    cd scripts
    pip install module
    
    0 讨论(0)
  • 2020-12-03 07:35

    This did my head in as well, and turns out, the only thing I needed to do is RESTART Pycharm. Sometimes after you've installed the pip, you can't load it into your project, even if the pip shows as installed in your Settings. Bummer.

    0 讨论(0)
提交回复
热议问题