How to Use Installed Packages in Pycharm

How do I use installed packages in PyCharm?

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.

Use Globally Installed Packages in PyCharm pipenv's?

You can add global site-packages to a new virtual environment with:

python3 -m venv venv-name --system-site-packages

or if you want to create a virtual env through PyCharm go to

File > Settings... > Project > Python interpreter > Add...

and check Inherit global site-packages when creating a new environment.

How do I install packages in PyCharm for all projects?

This is depending on your project settings, the project interpreter to be specific.

The project interpreter can be set to one of the following:

  • an interpreter installed globally on your system
  • an interpreter in a shared virtual environment
  • an interpreter in a virtual environment associated with a project

Now the approach I'd recommend would be to create a shared virtual environment where you install your packages to, and use this environment for all your project.

That way, you have the desired result of needing to install your packages only once, but still have an environment isolated from your system environment.

To create such an environment, follow these steps:

  1. Settings -> Project -> Project Interpreter
  2. Click the cogwheel / gear icon right-side the interpreter dropdown
  3. Select "Add Local..." -> Virtualenv Environment
  4. Select a path as a root directory for the new environment
  5. Select base interpreter you want to use
  6. Tick the checkbox "Make available to all projects"
  7. Click the "OK" button to save the new environment

PyCharm does not recognize installed package

PyCharm does not use the same python interpreter as the one you installed package for.

As @crissal said, you can use PyCharm package manager to install packages, or configure it to recognize the one you already have:

  1. In your cmd, type which python and you'll get something like /usr/bin/python (on win it might be different but doesn't matter). That's the path of your default interpeter.
  2. In PyCharm: Preferences -> Project -> Python Interpreter
  3. Choose path if listed, or Show all -> + -> find and select path
  4. Now in top right corner of the window, next to run button, select interpeter dropdown and Edit configuration
  5. Select correct Python interpreter, give it a few moments PyCharm will figure out your nltk dependency

I would strongly suggest using virtual environment for each project, in order not to mix dependencies.



Related Topics



Leave a reply



Submit