How do I use installed packages in PyCharm?

smurff picture smurff · Nov 10, 2013 · Viewed 567.4k times · Source

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

from gnuradio import gr

fails as an undefined reference. However, it works fine in the Python interpreter from the command line.

GNURadio works fine with python outside of Pycharm. Everything is installed and configured how I want it.

Gnuradio is located at /usr/local/lib/python2.7/site-packages/gnuradio

Also:

PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages/gnuradio

Answer

Brigand picture Brigand · Nov 10, 2013

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.