点不起作用,无法卸载

时间:2016-06-25 20:20:53

标签: python ubuntu pip

我遇到python包安装程序pip的问题。当我尝试在Pycharm中安装软件包时,出现以下错误:

  

错误:Python打包工具' pip'找不到

如果我尝试使用pip从终端安装软件包,我会

      $ sudo pip install matplotlib
  Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==7.1.0', 'console_scripts', 'pip')()
  File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg
/pkg_resources/__init__.py", line 558, in load_entry_point
  File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg    /pkg_resources/__init__.py", line 2682, in load_entry_point
  File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/pkg_resources/__init__.py", line 2355, in load
  File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/pkg_resources/__init__.py", line 2361, in resolve
ImportError: No module named 'pip'

我试图通过easy_install

卸载pip
$ sudo easy_install -mxN pip
Searching for pip
Best match: pip 7.1.0
Processing pip-7.1.0-py3.5.egg

Using /usr/local/lib/python3.5/dist-packages/pip-7.1.0-py3.5.egg
Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, in order to select the desired version:
    pkg_resources.require("pip")  # latest installed version
    pkg_resources.require("pip==7.1.0")  # this exact version
    pkg_resources.require("pip>=7.1.0")  # this version or higher

和pip

  $ sudo pip uninstall pip
  Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==7.1.0', 'console_scripts', 'pip')()
  File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg
/pkg_resources/__init__.py", line 558, in load_entry_point
  File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg    /pkg_resources/__init__.py", line 2682, in load_entry_point
  File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/pkg_resources/__init__.py", line 2355, in load
  File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/pkg_resources/__init__.py", line 2361, in resolve
ImportError: No module named 'pip'

但文件easy_install; easy_install-3.5; f2py; pip; pip3; pip3.5仍然保留在/ usr / local / bin中。我认为这些文件无法正确重新安装pip。

我使用的是Ubuntu 16.04。我使用的是python 3.5 我该怎么做才能安装python包?

修改

重新安装python后:sudo apt install python3-pip

如果尝试安装任何软件包,我仍然会收到错误:

sudo pip install cairocffi
[sudo] password for olger: 
The directory '/home/olger/.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.
The directory '/home/olger/.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.
Collecting cairocffi
  Downloading cairocffi-0.7.2.tar.gz (75kB)
    100% |████████████████████████████████| 81kB 491kB/s 
    Complete output from command python setup.py egg_info:
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
    compilation terminated.
    Traceback (most recent call last):
      File "/usr/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
        extra_postargs)
      File "/usr/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
        spawn(cmd, dry_run=self.dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 36, in spawn
        _spawn_posix(cmd, search_path, dry_run=dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
        % (cmd, exit_status))
    distutils.errors.DistutilsExecError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/bdist_egg.py", line 160, in run
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/bdist_egg.py", line 146, in call_command
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/install_lib.py", line 10, in run
      File "/usr/lib/python3.5/distutils/command/install_lib.py", line 109, in build
        self.run_command('build_ext')
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/build_ext.py", line 49, in run
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
        self.build_extensions()
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 447, in build_extensions
        self._build_extensions_serial()
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 472, in _build_extensions_serial
        self.build_extension(ext)
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/build_ext.py", line 174, in build_extension
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 532, in build_extension
        depends=ext.depends)
      File "/usr/lib/python3.5/distutils/ccompiler.py", line 574, in compile
        self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
      File "/usr/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
        raise CompileError(msg)
    distutils.errors.CompileError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 152, in save_modules
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 193, in setup_context
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 237, in run_setup
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 267, in run
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 236, in runner
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 46, in _execfile
      File "/tmp/easy_install-zlcvz3si/cffi-1.7.0/setup.py", line 192, in <module>
      File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/easy_install.py", line 1056, in run_setup
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 240, in run_setup
      File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 193, in setup_context
      File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 164, in save_modules
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 139, in resume
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/compat.py", line 65, in reraise
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 152, in save_modules
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 193, in setup_context
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 237, in run_setup
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 267, in run
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 236, in runner
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/sandbox.py", line 46, in _execfile
      File "/tmp/easy_install-zlcvz3si/cffi-1.7.0/setup.py", line 192, in <module>
      File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-u6rhv636/cairocffi/setup.py", line 65, in <module>
        **cffi_args
      File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/dist.py", line 268, in __init__
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/dist.py", line 313, in fetch_build_eggs
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/pkg_resources/__init__.py", line 836, in resolve
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/pkg_resources/__init__.py", line 1081, in best_match
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/pkg_resources/__init__.py", line 1093, in obtain
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/dist.py", line 380, in fetch_build_egg
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/easy_install.py", line 629, in easy_install
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/easy_install.py", line 659, in install_item
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/easy_install.py", line 842, in install_eggs
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/easy_install.py", line 1070, in build_and_install
      File "/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg/setuptools/command/easy_install.py", line 1058, in run_setup
    distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-u6rhv636/cairocffi/
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

编辑2: 另一件有趣的事情是,如果我尝试运行任何PIP命令,我会得到:

$ pip show pycairo
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

但如果我检查PIP版本,我会得到:

$ pip --version
pip 8.1.2 from /home/olger/.local/lib/python3.5/site-packages (python 3.5)

也许是因为pip的最后版本没有正确地解决。

0 个答案:

没有答案