无法使用 pip 安装 Pandas

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49554622/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 05:23:13  来源:igfitidea点击:

Not able to install pandas using pip

pythonpython-3.xpandas

提问by Sandie

While installing pandasusing pip, I'm getting error. Can someone please help me out with fixing this issue. I'm using python 3.4 on windows10.

pandas使用 pip安装时,出现错误。有人可以帮我解决这个问题。我在 windows10 上使用 python 3.4。

set build\lib.win-amd64-3.4\pandas/_version.py to '0.22.0'
    running build_ext
    building 'pandas._libs.hashing' extension
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\sthakur1\AppData\Local\Temp\pip-build-2lweg8a9\pandas\setup.py", line 743, in <module>
        **setuptools_kwargs)
      File "C:\Python34\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Python34\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\Python34\lib\distutils\command\install.py", line 539, in run
        self.run_command('build')
      File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Python34\lib\distutils\command\build.py", line 126, in run
        self.run_command(cmd_name)
      File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Python34\lib\distutils\command\build_ext.py", line 339, in run
        self.build_extensions()
      File "C:\Users\sthakur1\AppData\Local\Temp\pip-build-2lweg8a9\pandas\setup.py", line 385, in build_extensions
        build_ext.build_extensions(self)
      File "C:\Users\sthakur1\AppData\Local\Temp\pip-build-2lweg8a9\pandas\setup.py", line 161, in build_extensions
        _build_ext.build_extensions(self)
      File "C:\Python34\lib\distutils\command\build_ext.py", line 448, in build_extensions
        self.build_extension(ext)
      File "C:\Python34\lib\distutils\command\build_ext.py", line 503, in build_extension
        depends=ext.depends)
      File "C:\Python34\lib\distutils\msvc9compiler.py", line 460, in compile
        self.initialize()
      File "C:\Python34\lib\distutils\msvc9compiler.py", line 371, in initialize
        vc_env = query_vcvarsall(VERSION, plat_spec)
      File "C:\Python34\lib\site-packages\setuptools\msvc9_support.py", line 52, in query_vcvarsall
        return unpatched['query_vcvarsall'](version, *args, **kwargs)
      File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall
        raise ValueError(str(list(result.keys())))
    ValueError: ['path']

    ----------------------------------------
Command "C:\Python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\sthakur1\AppData\Local\Temp\pip-build-2lweg8a9\pandas\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\sthakur1\AppData\Local\Temp\pip-todgu5lt-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\sthakur1\AppData\Local\Temp\pip-build-2lweg8a9\pandas\

回答by Thomas Goodyear

Have you tried running your CMD window as an administrator? And try this instead:

您是否尝试过以管理员身份运行 CMD 窗口?试试这个:

python -m pip install pandas

Also make sure that your python installation folder is in your 'PATH' Environment Variable

还要确保您的python安装文件夹在您的“PATH”环境变量中

回答by hygull

The best solution would be to install Anaconda3 in your system. As it is a Big Python (with a great support of libraries for Data science and many more).

最好的解决方案是在您的系统中安装 Anaconda3。因为它是一个大 Python(对数据科学等库有很大的支持)。

I love pandasand I found Anacondaa great tool to work. Jupyter notebookis also a great tool to learn, try and enjoy working with Data science. I have worked with 1/2 clients who (had PHD in mathematics or an employee in any organization) suggested me to choose Anacondaand Jupyter notebook.

我喜欢Pandas,我发现Anaconda是一个很好的工作工具。Jupyter notebook也是学习、尝试和享受数据科学工作的绝佳工具。我曾与 1/2 客户(拥有数学博士学位或任何组织的员工)建议我选择AnacondaJupyter notebook

  • Please uninstall Python 3 from your System. Also remove related paths from PATHenvironment variable.

  • Visit https://www.anaconda.com/download/#windowsand download Python 3.7.

  • Install it, do not check (?) if the installation wizard asks for setting environment variables (it causes issues later).

  • Also make a note of Anaconda'sinstallation directory basically it would be C:\Users\sthakur1\Anaconda3in your case, let's take it as an example.

  • Just click nextby accepting the defaults. At the end of installation, it will ask you to install VScode, please install that, just click on install VSCodeand installer will do the installation.

  • Once done, click on close/finishbutton. Now it's time to add the following paths to PATHenvironment variable one by one.

  • 请从您的系统中卸载 Python 3。同时从PATH环境变量中删除相关路径。

  • 访问https://www.anaconda.com/download/#windows并下载Python 3.7

  • 安装它,不要检查 (?) 安装向导是否要求设置环境变量(稍后会导致问题)。

  • 还要记下Anaconda的安装目录,基本上C:\Users\sthakur1\Anaconda3你的情况就是这样,我们以它为例。

  • 只需接受默认值即可单击下一步。在安装结束时,它会要求您安装VScode,请安装它,只需单击安装 VSCode,安装程序就会进行安装。

  • 完成后,单击关闭/完成按钮。现在是时候将以下路径一一添加到PATH环境变量中。

The last 2 are optional, you can skip. Actually, that I saw when I check the automatic path settings option the installer also add these 3 as well.

Here https://dev.to/hygull/setting-anaconda-path-on-windows-2dmnis my little article that explains this which can be easily found on Google (Chrome) just by typing Anaconda path settingsand clicking on 2nd link(mostly), as 1st one takes to Stackoverflow.

最后2个是可选的,可以跳过。实际上,当我检查自动路径设置选项时,我看到安装程序也添加了这 3 个选项。

这里https://dev.to/hygull/setting-anaconda-path-on-windows-2dmn是我的小文章,解释了这一点,只需键入Anaconda path settings并单击第二个链接(大部分)即可在 Google (Chrome) 上轻松找到,作为第一个需要 Stackoverflow。

C:\Users\sthakur1
C:\Users\sthakur1\Library\bin
C:\Users\sthakur1\Scripts
C:\Users\sthakur1\Library\mingw-w64\bin
C:\Users\sthakur1\Library\usr\bin

Finally, you can open a new terminal, try the following statements.

最后,您可以打开一个新终端,尝试以下语句。

>>> import pandas as pd
>>> import numpy as np
>>> 
>>> df = pd.DataFrame({"fullname": ["A N",  "P Y"],  "age": [34,  67]}) 
>>> df

And now you are done. Please comment if you face any issue.

现在你已经完成了。如果您遇到任何问题,请发表评论。

回答by chris mahn

i believe it has to do with version of PIP the way to fix it is to install pip version 19.3.1 python -m pip install pip==19.3.1 then you can upgrade to latest pip if needed and it should work fine.

我相信这与 PIP 的版本有关,修复它的方法是安装 pip version 19.3.1 python -m pip install pip==19.3.1 然后你可以根据需要升级到最新的 pip,它应该可以正常工作。

回答by KonnovArt

This turned out to be a common issue while instaling pandas with pip on python 3.4. That's actually a known bug confirmed by pandas package developers on https://github.com/pandas-dev/pandas/issues/20775

事实证明,在 python 3.4 上使用 pip 安装 Pandas 时,这是一个常见问题。这实际上是 pandas 包开发人员在https://github.com/pandas-dev/pandas/issues/20775上确认的一个已知错误

The simplest solution should be:

最简单的解决方案应该是:

pip install 'pandas<0.21'

回答by hari

Use this command to install PANDAS

使用此命令安装 PANDAS

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pandas -vvv

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pandas -vvv