I\'m trying to use pip to install a package. I try to run pip install
from the Python shell, but I get a SyntaxError
. Why do I get this error? H
Programmatically, the following currently works. I see all the answers post 10.0 and all, but none of them are the correct path for me. Within Kaggle for sure, this apporach works
from pip._internal import main as _main
package_names=['pandas'] #packages to install
_main(['install'] + package_names + ['--upgrade'])
pip is run from the command line, not the Python interpreter. It is a program that installs modules, so you can use them from Python. Once you have installed the module, then you can open the Python shell and do import selenium
.
The Python shell is not a command line, it is an interactive interpreter. You type Python code into it, not commands.
To run pip in Python 3.x, just follow the instructions on Python's page: Installing Python Modules.
python -m pip install SomePackage
Note that this is run from the command line and not the python shell (the reason for syntax error in the original question).
Use the command line, not the Python shell (DOS, PowerShell in Windows).
C:\Program Files\Python2.7\Scripts> pip install XYZ
If you installed Python into your PATH using the latest installers, you don't need to be in that folder to run pip
Terminal in Mac or Linux
$ pip install XYZ
Try upgrade pip with the below command and retry
python -m pip install -U pip
you need to type it in cmd not in the IDLE. becuse IDLE is not an command prompt if you want to install something from IDLE type this
>>>from pip.__main__ import _main as main
>>>main(#args splitted by space in list example:['install', 'requests'])
this is calling pip like pip <commands>
in terminal. The commands will be seperated by spaces that you are doing there to.