搞砸了我的pip和python安装

时间:2018-08-16 19:24:31

标签: python pip

与linux mint合作,昨天我去了pip安装一个软件包。

user@mycomp ~ $ pip install bitmex-ws
The program 'pip' is currently not installed. You can install it by typing:
sudo apt install python-pip

好,安装点子

jason@speedylinux ~ $ sudo apt install python-pip

看来一切正常。再试一次...

jason@speedylinux ~ $ pip install bitmex-ws
Collecting bitmex-ws
Downloading https://files.pythonhosted.org/packages/f0/5c/6ea7f43b49cf46b0d1552abd6ab89aae4f74641ebca2d836c52737300ea1/bitmex-ws-0.3.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named setuptools
You are using pip version 8.1.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

认为这是最后一个错误的问题(但实际上实际上只是未安装setuptools),就像上面说的那样...

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

在这一点上,我很沮丧,做了很多谷歌搜索和搜索。最终在以下情况下这样做:

jason@speedylinux ~ $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

成功。

jason@speedylinux ~ $ python get-pip.py
/tmp/tmpM7KfNh/pip.zip/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
Collecting pip
  Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 18.0
    Uninstalling pip-18.0:
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/bin/pip3'
Consider using the `--user` option or check the permissions.

这看起来很奇怪。 所以我做了不明智的选择(不要运行)

sudo python get-pip.py

这显然不是一个好主意。当时不知道。

那回来了

    The directory '/home/jason/.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/jason/.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 pip
  Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 4.5MB/s 
Installing collected packages: pip
  Found existing installation: pip 18.0
    Uninstalling pip-18.0:
      Successfully uninstalled pip-18.0
Successfully installed pip-18.0

现在它搞砸了。 不知道该怎么走。我的最终目标是安装该bitmex软件包。 这是一些命令的结果

jason@speedylinux ~ $ python -m pip

/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)

Usage:   
  /usr/bin/python -m pip <command> [options]

Commands:
  install                     Install packages.
  download ... etc

jason@speedylinux ~ $ pip
bash: /usr/bin/pip: No such file or directory
jason@speedylinux ~ $ which python
/usr/bin/python
jason@speedylinux ~ $ which python3
/usr/bin/python3
jason@speedylinux ~ $ which pip
/home/jason/.local/bin/pip
jason@speedylinux ~ $ pip
bash: /usr/bin/pip: No such file or directory
jason@speedylinux ~ $ pip install bitmex-ws
bash: /usr/bin/pip: No such file or directory

任何帮助,谢谢

2 个答案:

答案 0 :(得分:1)

如您所见,

python-pip是一个安装了aptitude的软件包,没有明确链接到python发行版。我要做的是卸载当前的python安装,然后使用您喜欢的版本重新安装。

python get-pip.py仅应在未本地安装pip的版本(即,不是python 3.x)上运行。如果您正在运行python3.x,只需从tar.gz或二进制文件重新安装。然后,确保linux盒子指向的是python安装。

通常pip-install打包时,您会希望python -m pip install...确保没有使用apt安装的pip

答案 1 :(得分:-1)

此外,如果您使用的是Linux,我认为您应该考虑以下事项

sudo apt update

sudo apt upgrade