Pip install doesn't work in the Python console

It seems that there is an error in the Internet, but I tried to solve it - it did not help:

Code:

>>> pip install

Mistake:

File "<stdin>", line 1
    pip install
              ^
SyntaxError: invalid syntax

What should I do? Everything is fine with the path like

Author: Pavel Mayorov, 2018-03-02

5 answers

In your line I see:

>>> pip install ...

So I understand that you run python interactively (the first time I ran it myself). pip runs from the command line of your OS.

Run cmd, write pip install ... and Enter

 11
Author: Anton Kulago, 2018-03-03 00:03:39

Is there nothing that bothers you? That let's say the error is not typical for cmd.exe.

Decision:

You go to cmd.exe and write

>>>cd путь_к_python\Scripts
>>>pip install модуль который вы хотите установить

And for some reason you call the command for cmd from the python console...

 4
Author: Gleb, 2018-03-04 17:09:42

If the 3rd version of python, then in cmd, try pip3 install "название библиотеки"

 1
Author: lynx, 2018-03-03 06:13:27

Not sure, but

python -m pip install SomePackage

Https://docs.python.org/3/installing/index.html#basic-usage


If I'm not mistaken, since the third version of python, a construction of the form

python -m `имя модуля`

For example

python -m http.server 8000

View version

python -V

In the third python, create a virtual environment and install the package

According to the steps, checked in Linux, in Windows, presumably, only the first two steps differ

To create directory

mkdir test

Go to it

cd test

Create an environment

python3 -m venv .env

Go to it

source .env/bin/activate

Install the package

python -m pip install django

The environment will be located in the directory .env

Https://stackoverflow.com/a/47196099/4794368 - and here you can read how to combine all this with VSCode

 0
Author: qwabra, 2018-03-02 17:44:49

In short, I found this code: python -m pip install -U pip apparently pip was not installed (or updated) and it helped. and then pip install django worked all this should be done on the command line

 0
Author: Антон Василенко, 2018-03-03 16:26:57