简体   繁体   中英

How can I install packages?

I can't install a package with the pip or pip3 command and I can't install it from the Python Interpreter in PyCharm too. I can't tap on the '+' at the Python Interpreter in PyCharm. I get this error:

pip command not found

Here is what you can try.

  1. Lets check python installation.
C:\Users\User>python --version
Python 3.10.5

C:\Users\User>

If you get the version as 3.x, then we are good, else goto your python installation directory and copy its path and then add it to your environment variable PATH.

  1. Check PIP available or not.
C:\Users\User>pip --version
pip 22.3 from C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\pip (python 3.10)

C:\Users\User>

if above didn't work then add pip path to PATH environment variable which would be something similar to above output.

  1. Now we are ready to install any package

Just do pip install package-name for testing, you can try: pip install numpy If it still throws error, try below one python -m pip install numpy if it still throws error, then you might need to clean your python installation.

3 commands

sudo apt update
sudo apt install python3-pip
pip3 install <package_name>

or maybe

sudo apt install <package_name> -y

It looks like you don't have pip installed on $PATH . The following command will run pip without any adjustments to $PATH :

python3 -m pip install <some_module>

Pay attention to the -m , this stands for modules and runs the pip program inside the python3 interpreter (I don't know exact definition here, if anyone wishes to correct me I will update the answer)

However, if this doesn't work then you may not have pip installed, and can be installed by running:

python3 -m ensurepip --upgrade

Then, reload your shell via the following (replace bash with your shell):

exec bash

Running pip --version should now work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM