【问题标题】:Error after pip upgrade using command "pip3 install --upgrade pip"使用命令“pip3 install --upgrade pip”进行 pip 升级后出错
【发布时间】:2019-11-11 06:13:13
【问题描述】:

我的 python 库 pandas、numpy、matplotlib 之前工作过,现在我使用命令 pip3 install --upgrade pip 用于升级 pip 和下一个“import pandas 命令不起作用”。

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pandas
  File "/home/desktop/.local/lib/python3.5/site-packages/pandas/__init__.py", line 17, in <module>
    "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['/home/desktop/.local/lib/python3.5/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

接下来我尝试使用命令 sudo pip3 install pandas 安装熊猫,我收到以下错误

desktop@desktop-All-Series:~$ sudo pip3 install pandas
WARNING: The directory '/home/desktop/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/desktop/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: pandas in ./.local/lib/python3.5/site-packages (0.25.3)
ERROR: Package 'pandas' requires a different Python: 3.5.2 not in '>=3.5.3'

desktop@desktop-All-Series:~$ pip3 install --upgrade pip
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

我使用的是 ubuntu 16.04 如何解决这个问题?

【问题讨论】:

    标签: python python-3.x pandas pip


    【解决方案1】:

    它说 pip3 不支持。 您可以使用此命令。 试试看,

    conda install pandas
    

    也试试这个 cmd

    pip3 install --upgrade setuptools pip
    

    【讨论】:

      【解决方案2】:

      使用命令后现在可以工作了

      python3 -m pip install pandas --user
      
      desktop@desktop-All-Series:~$ python3 -m pip install pandas --user
      Collecting pandas
        Using cached https://files.pythonhosted.org/packages/74/24/0cdbf8907e1e3bc5a8da03345c23cbed7044330bb8f73bb12e711a640a00/pandas-0.24.2-cp35-cp35m-manylinux1_x86_64.whl
      Requirement already satisfied: python-dateutil>=2.5.0 in ./.local/lib/python3.5/site-packages (from pandas) (2.8.1)
      Collecting numpy>=1.12.0
        Using cached https://files.pythonhosted.org/packages/ab/e9/2561dbfbc05146bffa02167e09b9902e273decb2dc4cd5c43314ede20312/numpy-1.17.4-cp35-cp35m-manylinux1_x86_64.whl
      Requirement already satisfied: pytz>=2011k in ./.local/lib/python3.5/site-packages (from pandas) (2019.3)
      Requirement already satisfied: six>=1.5 in ./.local/lib/python3.5/site-packages (from python-dateutil>=2.5.0->pandas) (1.13.0)
      Installing collected packages: numpy, pandas
        Found existing installation: numpy 1.11.1
          Uninstalling numpy-1.11.1:
            Successfully uninstalled numpy-1.11.1
        WARNING: The scripts f2py, f2py3 and f2py3.5 are installed in '/home/desktop/.local/bin' which is not on PATH.
        Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      Successfully installed numpy-1.17.4 pandas-0.24.2
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-06-01
        • 2021-11-15
        • 2021-03-25
        • 1970-01-01
        • 2021-05-04
        • 1970-01-01
        • 2016-04-26
        • 2021-07-12
        相关资源
        最近更新 更多