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.
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:
- Settings -> Project -> Project Interpreter
- Click the cogwheel / gear icon right-side the interpreter dropdown
- Select "Add Local..." -> Virtualenv Environment
- Select a path as a root directory for the new environment
- Select base interpreter you want to use
- Tick the checkbox "Make available to all projects"
- 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:
- 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. - In PyCharm:
Preferences
->Project
->Python Interpreter
- Choose path if listed, or
Show all
->+
-> find and select path - Now in top right corner of the window, next to run button, select interpeter dropdown and
Edit configuration
- Select correct
Python interpreter
, give it a few moments PyCharm will figure out yournltk
dependency
I would strongly suggest using virtual environment for each project, in order not to mix dependencies.
Related Topics
How to Dynamically Build a Json Object
What Causes a Python Segmentation Fault
Json.Loads() Decodes Only With Raw String Literal
How to Split an Integer into an Array of Digits
Python/Regex - How to Extract Date from Filename Using Regular Expression
Typeerror: Image Data Can Not Convert to Float
Python, Deleting All Files in a Folder Older Than X Days
Comparing Two Dataframes and Getting the Differences
Why Is This Python Script With Matplotlib So Slow
How to Disable the Security Certificate Check in Python Requests
How to Write Multiple Images (Subplots) into One Image
Possible to Get User Input Without Inserting a New Line
How to Block Comment Code in the Ipython Notebook
Pandas: Update Column Values from Another Column If Criteria
Discord.Py Show Who Invited a User
Pandas Get Frequency of Item Occurrences in a Column as Percentage
Could Not Find a Version That Satisfies the Requirement in Python