如何从Windows cmd上的pip安装 pandas ? [英] How to install pandas from pip on windows cmd?
问题描述
我正在尝试使用pip安装熊猫,以运行一些基于熊猫的Python程序.我已经安装了pip.我尝试使用谷歌搜索和SO'ing,但没有找到解决此错误的方法.有人可以分享您的意见吗?
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
错误:
pip is not recognized as an internal or external command, operable program or batch file.
推荐答案
由于Windows中没有同时安装pip
和python
命令,因此您将需要使用Windows替代py
默认情况下,安装Python时.然后,您可以选择在py
命令之后指定通用或特定的版本号.
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 =%
或者,为了使pip
在没有py -m
部分的情况下工作,您将需要在PATH环境中添加点变量.
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
解决方案:
这是由于您的SSL证书无法验证主机服务器引起的.您可以将pypi.python.org添加到受信任的主机,或指定备用SSL证书.有关更多信息,请参见此帖子. (感谢Anuj Varshney提出的建议)
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
问题:
PermissionError: [WinError 5] Access is denied
解决方案:
这是由于您没有修改Python站点包文件夹的权限引起的.您可以使用以下其中一种方法来避免这种情况:
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:
-
以管理员身份运行Windows命令提示符(由于DataGirl的建议):
Run Windows Command Prompt as administrator (thanks to DataGirl's suggestion) by:
- + R 打开运行
- 在搜索框中输入
cmd.exe
- CTRL + SHIFT + ENTER
- 步骤1-3的另一种方法是手动找到cmd.exe,右键单击,然后单击以管理员身份运行".
- + R to open run
- type in
cmd.exe
in the search box - CTRL + SHIFT + ENTER
- An alternative method for step 1-3 would be to manually locate cmd.exe, right click, then click Run as Administrator.
在使用pip进行安装时,通过添加--user
选项,在用户模式中运行
pip.通常会将软件包安装到本地%APPDATA%Python文件夹中.
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
这篇关于如何从Windows cmd上的pip安装 pandas ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!