How do I use installed packages in PyCharm?

后端 未结 13 1435
暗喜
暗喜 2020-11-22 16:20

In PyCharm, I\'ve added the Python environment /usr/bin/python. However,

from gnuradio import gr

fails as an unde

相关标签:
13条回答
  • 2020-11-22 16:32

    I'm new to PyCharm (using 2018.3.4 CE) and Python so I rotely tried to follow each of the above suggestions to access the PIL (Pillow) package which I knew was in system-site-packages. None worked. I was about to give up for the night when I happened to notice the venv/pyvenv.cfg file under my project in the Project Explorer window. I found the line "include-system-site-packages = false" in that file and so I changed it to "true". Problem solved.

    0 讨论(0)
  • 2020-11-22 16:34

    DON'T change the interpreter path.

    Change the project structure instead:

    File -> Settings -> Project -> Project structure -> Add content root

    0 讨论(0)
  • 2020-11-22 16:38

    In my PyCharm 2019.3, select the project, then File ---> Settings, then Project: YourProjectName, in 'Project Interpreter', click the interpreter or settings, ---> Show all... ---> Select the current interpreter ---> Show paths for the selected interpreter ---> then click 'Add' to add your library, in my case, it is a wheel package

    0 讨论(0)
  • 2020-11-22 16:39

    Adding a Path

    Go into File → Settings → Project Settings → Project Interpreter.

    Then press configure interpreter, and navigate to the "Paths" tab.

    pycharm path tab

    Press the + button in the Paths area. You can put the path to the module you'd like it to recognize.

    But I don't know the path..

    Open the python interpreter where you can import the module.

    >> import gnuradio
    >> gnuradio.__file__
    "path/to/gnuradio"
    

    Most commonly you'll have a folder structure like this:

    foobarbaz/
      gnuradio/
        __init__.py
        other_file.py
    

    You want to add foobarbaz to the path here.

    0 讨论(0)
  • 2020-11-22 16:39

    My version is PyCharm Professional edition 3.4, and the Adding a Path part is different.

    You can go to "Preferences" --> "Project Interpreter". Choose the tool button at the right top corner.

    Then choose "More..." --> "Show path for the selected interpreter" --> "Add". Then you can add a path.

    0 讨论(0)
  • 2020-11-22 16:47

    For PyCharm Community Edition 2016.3.2 it is:

    "Project Interpreter" -> Top right settings icon -> "More".

    Then on the right side there should be a packages icon. When hovering over it it should say "Show paths for selected interpreter". Click it.

    Then click the "Add" button or press "alt+insert" to add a new path.

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