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

时间:2018-12-30 14:19:56

标签: python python-3.x pandas tensorflow pip

我在Mac osx上安装了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张量流 成功安装了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 tensorflow-1.12.0 termcolor-1.1.0 werkzeug -0.14.1

但是当我尝试用熊猫做同样的事情时 $ python3 -m pip install-用户熊猫

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

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 egg_info中使用python3

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

1 个答案:

答案 0 :(得分:0)

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

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if(isFirstTimeClick){
                isFirstTimeClick=false;
                Toast.makeText(PicturePreviewActivity.this, "First Time Click", Toast.LENGTH_SHORT).show();
            }else {
                isFirstTimeClick=true;
                Toast.makeText(PicturePreviewActivity.this, "Second Time Click", Toast.LENGTH_SHORT).show();
            }
        }
    });

OR

pip3 install pandas --no-build-isolation

OR

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

OR

sudo pip install pandas

,对于使用mojave的mac终端,

pip install --user pandas

pip3 install pandas

之后

pip 3 install --upgrade pip