Installing python packages in Pycharm and cmd - Stack Overflow
python - How to import packages into Pycharm using PIP? - Stack Overflow
linux - Ubuntu Python PyCharm How to use and install new packages - Unix & Linux Stack Exchange
python - How do I install packages in PyCharm for all projects? - Stack Overflow
How do I install multiple packages at once in PyCharm?
Can I install packages in PyCharm Community Edition?
Why can't PyCharm find my installed package?
This is guide for installing the pip packages from Python Console in Pycharm IDE.
Do not forget to run Pycharm as administrator if you are using windows OS before installing the packages.
First of all import the pacakage of pip in python console.
import pip
Installation of Package.
pip.main(['install', '<package_name>'])
Examples
The below command will upgrade the version of package setuptools.
pip.main(['install','--upgrade','setuptools'])
The below command will install the scikit-learn and numpy packages.
pip.main(['install','numpy','scikit-learn'])
The below command will uninstall the scikit-learn package.
pip.main(['uninstall','scikit-learn'])

I found someone else's answer that works for me:
You need to use
import pip
pip.main(['install','packagename'])
Which allows you to manually install packages through pip using Python code.
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 environmentassociated 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
You can download Package from the Pycharm IDE
1. Open Pycharm and Go to File
2. Click on Settings
3. On left Side, You will find Projects Option. Click & Expend it
4. Click on Interpreter
5. A list of installed package will be shown
6. On Right Side, You will see a + button. Click This to install new package
7. A window will appear with Search bar, then search your package name and hit install button.
All steps are taken from this One minute Video.
I pip installed from CMD a python package "pip install example" and it installs to "site-packages" folder where python 3.11 is installed to.
That works and my code in pycharm runs.
Then I uninstalled in cmd using command "pip uninstall example" and reinstalled the package from within pycharm's package installer window (hit the + button, search package click install). First thing I noticed is I can't find where the package was installed to in my computer.
After that if I click run, everything works, but I can no longer run that script from the terminal as it says the package is not installed.
From now on then, should I completely ignore pycharm package install functionality and just install packages via pip from the terminal either in pycharm or CMD? Is this the done thing?
Edit: After deleting my test project to see if the below works, it doesn't! My new pycharm test project is pointing at my python install, where example package is still installed, but clicking the run button (or shift f10) yields the "no module named 'example' error. But it will run from the terminal. Please help!
I'm thinking that if I pip install via the terminal from now on, those packages will always be available so long as I point pycharm to where python is installed on my computer when creating a new project.
Thanks for reading, any advice here would be greatly appreciated.