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
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
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...
If the 3rd version of python, then in cmd, try pip3 install "название библиотеки"
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
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