繁体   English   中英

在Mac上使用pip安装pandas模块时出现问题

[英]problems installing pandas module with pip on mac

我在Mac OS X上安装了2个python安装程序。

$ which python
/usr/bin/python

$ which python3
/Library/Frameworks/Python.framework/Versions/3.4/bin/python3

$ pip install --upgrade setuptools
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/37/06/754589caf971b0d2d48f151c2586f62902d93dc908e2fd9b9b9f6aa3c9dd/setuptools-40.6.3-py2.py3-none-any.whl (573kB)
    100% |████████████████████████████████| 655kB 1.5MB/s 
Installing collected packages: setuptools
  Found existing installation: setuptools 2.1
    Uninstalling setuptools-2.1:
      Successfully uninstalled setuptools-2.1
Successfully installed setuptools-40.6.3
$ which pip
/Library/Frameworks/Python.framework/Versions/3.4/bin/pip

$ pip -V
pip 18.1 from /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip (python 3.4)

我可以使用pip fine安装模块。 例如$ python3 -m pip install --user tensorflow成功安装了absl-py-0.6.1 astor-0.7.1 gast-0.2.0 grpcio-1.17.1 markdown-3.0.1 protobuf-3.6.1 tensorboard-1.12。 1张量流1.12.0 termcolor-1.1.0 werkzeug-0.14.1

但是当我尝试使用pandas $ python3 -m pip install --user pandas时

它通过收集和下载依赖项一直进行到最后,但是由于以下错误而出错。

Collecting pandas
  Downloading https://files.pythonhosted.org/packages/08/01/803834bc8a4e708aedebb133095a88a4dad9f45bbaf5ad777d2bea543c7e/pandas-0.22.0.tar.gz (11.3MB)
    100% |████████████████████████████████| 11.4MB 1.5MB/s 
  Installing build dependencies ... done
    Complete output from command python setup.py egg_info:
    Download error on https://pypi.org/simple/numpy/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:600) -- Some packages may not be found!
    Couldn't find index page for 'numpy' (maybe misspelled?)
    Download error on https://pypi.org/simple/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:600) -- Some packages may not be found!
    No local packages or working download links found for numpy>=1.9.0
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-install-r4n38agj/pandas/setup.py", line 743, in <module>
        **setuptools_kwargs)
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-build-env-fqe1gkak/lib/python3.4/site-packages/setuptools/__init__.py", line 142, in setup
        _install_setup_requires(attrs)
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-build-env-fqe1gkak/lib/python3.4/site-packages/setuptools/__init__.py", line 137, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-build-env-fqe1gkak/lib/python3.4/site-packages/setuptools/dist.py", line 586, in fetch_build_eggs
        replace_conflicting=True,
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-build-env-fqe1gkak/lib/python3.4/site-packages/pkg_resources/__init__.py", line 780, in resolve
        replace_conflicting=replace_conflicting
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-build-env-fqe1gkak/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1063, in best_match
        return self.obtain(req, installer)
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-build-env-fqe1gkak/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1075, in obtain
        return installer(requirement)
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-build-env-fqe1gkak/lib/python3.4/site-packages/setuptools/dist.py", line 653, in fetch_build_egg
        return cmd.easy_install(req)
      File "/private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-build-env-fqe1gkak/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 673, in easy_install
        raise DistutilsError(msg)
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('numpy>=1.9.0')

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/d5/k1w6m6xj5g727x952sdkkc1r0000gn/T/pip-install-r4n38agj/pandas/

问题似乎是它正在使用Python,而应该在python setup.py中使用python3.py egg_info

我如何确保pip在脚本中使用python3或是否存在其他问题?

您可以使用下面给出的任何代码

pip3 install pandas --no-build-isolation

要么

sudo apt-get install python3-pip
sudo -H pip3 install pandas

要么

sudo pip install pandas

要么

pip install --user pandas

对于使用mojave的mac终端,例如

pip3 install pandas

要么

pip 3 install --upgrade pip

pip install pandas

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM