简体   繁体   中英

Cannot install with pip

I've been trying to install discordpy through pip install discord.py but get a message as:

pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip install discordpy
+ ~~~
    + CategoryInfo          : ObjectNotFound: (pip:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I've done this in both cmd and windows power shell and in cmd, i get the error as:

'pip' is not recognized as an internal or external command, operable program or batch file.

I've tried a lot of things that I found on Stack Overflow but nothing worked. The Python version I'm using is 3.7.

Pip is confusing when starting to use it. It is BOTH an command line argument AND a python method.

However, you're falling into a pitfall I did too. If you want to use it as an inherent command line argument like > pip install [package] then you need to install the pip app. Good news is that you don't NEED to do that. Instead try running it as a python method:

> python -m pip install [package]

Since pip is bundled with the later versions of python(>3.4), you can run pip as a method of python.

So instead of installing using > pip install discord.py , use > python -m -3.7 pip install discord.py[voice]

The -3.7 tag tells which version to install to if you have multiple versions of python. For example, if you are using 3.8, you would use the -3.8 tag instead

Voice is for voice support which just adds PyNaCl to its list of dependencies and is completely optional if you are not interacting with VoiceChannels.

A common misconception is to not do pip install discord just because it says v1.0.1, but in reality, discord is just a mirror package of discord.py on PyPi because if you look deeper, discord.py is a dependency for discord . However, it's still recommended to install discord.py over discord

If you're using a VENV(Virtual ENVironment), install using the package manager or command line which comes with the IDE.

First off, check where your python path is. If you already know this, that's great. If not, then what you should do is write in this code in

 import sys for p in sys.path: print(p)

The 4th one is your Python path. Open that folder, and go into the "Scripts" folder. Go to that path in your CMD, and use the command again. If you don't find a Scripts folder, go to your Python path and write in your CMD python -m pip install <module> .

Let me know if I helped you!

If you get an error message saying that 'pip' or 'python' "is not recognized as an internal or external command", or something similar, you might have not adjusted your PATH system variable to include the executable paths pointing to either program. Alternatively, you may need to activate your virtual environment and use python -m pip... instead.

How to adjust the PATH variable on

How to activate your virtual environment:

  1. Navigate to the directory of your venv
  2. Windows: venv\Scripts\activate Unix/Mac: source venv/bin/activate (deactivate by typing deactivate)

Note: This answer is taken from the discord.py bot, R.Danny. You can join the official discord.py server to use the bot here: https://discord.com/invite/r3sSKJJ

Invoke command to get the response: !tag path

You can fix it as follow:

Method 1: Reinstall Python and make sure to check ADD TO PATH while doing so.

Method 2: Find the location of pip, normally it's as follow C:/Program Files/Python/scripts/pip. Then open your CMD and type: setx PATH C:/Program Files/Python/scripts/pip .

The reason behind your error is that PIP is installed on your computer but it's not linked with your CMD. To link it with your CMD it has to be inside your PATH within Environment Variables.

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