Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install pandas from pip on windows cmd?

I am trying to install pandas using pip to run some pandas-based Python programs. I already installed pip. I tried googling and SO'ing but didn't find a solution to this error. Can somebody share your inputs on this?

C:\> pip install pandas 

Error:

pip is not recognized as an internal or external command, operable program or batch file. 
like image 617
Teja Avatar asked Mar 20 '17 15:03

Teja


People also ask

Can you install pandas with pip?

pandas can be installed via pip from PyPI.

Which command is used to install pandas?

Type in the command “pip install manager”. Pip is a package install manager for Python and it is installed alongside the new Python distributions.


2 Answers

Since both pip nor python commands are not installed along Python in Windows, you will need to use the Windows alternative py, which is included by default when you installed Python. Then you have the option to specify a general or specific version number after the py command.

C:\> py      -m pip install pandas  %= one of Python on the system =% C:\> py -2   -m pip install pandas  %= one of Python 2 on the system =% C:\> py -2.7 -m pip install pandas  %= only for Python 2.7 =% C:\> py -3   -m pip install pandas  %= one of Python 3 on the system =% C:\> py -3.6 -m pip install pandas  %= only for Python 3.6 =% 

Alternatively, in order to get pip to work without py -m part, you will need to add pip to the PATH environment variable.

C:\> setx PATH "%PATH%;C:\<path\to\python\folder>\Scripts" 

Now you can run the following command as expected.

C:\> pip install pandas 

Troubleshooting:


Problem:

connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 

Solution:

This is caused by your SSL certificate is unable to verify the host server. You can add pypi.python.org to the trusted host or specify an alternative SSL certificate. For more information, please see this post. (Thanks to Anuj Varshney for suggesting this)

C:\> py -m pip install --trusted-host pypi.python.org pip pandas 

Problem:

PermissionError: [WinError 5] Access is denied 

Solution:

This is a caused by when you don't permission to modify the Python site-package folders. You can avoid this with one of the following methods:

  • Run Windows Command Prompt as administrator (thanks to DataGirl's suggestion) by:

    1. Windows-Key + R to open run
    2. type in cmd.exe in the search box
    3. CTRL + SHIFT + ENTER
    4. An alternative method for step 1-3 would be to manually locate cmd.exe, right click, then click Run as Administrator.
  • Run pip in user mode by adding --user option when installing with pip. Which typically install the package to the local %APPDATA% Python folder.

C:\> py -m pip install --user pandas 
  • Create a virtual environment.
C:\> py -m venv c:\path\to\new\venv C:\> <path\to\the\new\venv>\Scripts\activate.bat 
like image 80
Taku Avatar answered Sep 23 '22 12:09

Taku


In my opinion, the issue is because the environment variable is not set up to recognize pip as a valid command.

In general, the pip in Python is at this location:

C:\Users\user\AppData\Local\Programs\Python\Python36\Scripts > pip 

So all we need to do is go to Computer Name> Right Click > Advanced System Settings > Select Env Variable then under system variables > reach to Path> Edit path and add the Path by separating this path by putting a semicolon after the last path already was in the Env Variable.

Now run Python shell, and this should work.

like image 21
Rahul Yadav Avatar answered Sep 26 '22 12:09

Rahul Yadav