AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1164352
Accepted
Thanasis Mattas
Thanasis Mattas
Asked: 2019-08-09 07:11:26 +0800 CST2019-08-09 07:11:26 +0800 CST 2019-08-09 07:11:26 +0800 CST

无法使用 pip (ubuntu) [pip 配置了需要 TLS/SSL 的位置,但是 Python 中的 ssl 模块不可用。]

  • 772
$ sudo pip install numpy    # or anything else

错误:

The directory '/home/user/.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. (tried sudo -H, the rest errors persist)  
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.    
Collecting numpy  
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/  
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.  
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping  
$ python -V
Python 3.7.3  
$ pip -V
pip 19.0.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
$ whereis pip
pip: /usr/local/bin/pip2.7 /usr/local/bin/pip3.7 /usr/local/bin/pip /usr/local/bin/pip3.6  

pip3.6 出现在:

$ sudo su
$ update-alternatives --install /usr/bin/python python /usr/bin/python3 1

在 anaconda 环境中,pip 工作正常。

以安全的方式删除与 python 相关的东西——不破坏系统,并正确地重新安装东西,是一个更可取的解决方案吗?以及如何做到这一点?

我知道有很多类似的问题,但是我尝试了很多东西(显然,我搞砸了一些东西)并且我没有解决问题。

谢谢!

python3 pip
  • 1 1 个回答
  • 43805 Views

1 个回答

  • Voted
  1. Best Answer
    singrium
    2019-08-10T06:03:35+08:002019-08-10T06:03:35+08:00

    1-避免在sudo不需要时使用。
    2-由于您使用的是 Python3,因此在 Python3 中安装包的适当方法是使用 pip3。
    所以命令如下:pip3 install --user <package_name> 其中:

    • pip3适用于 Python3。

    • install使用 pip3 安装软件包。

    • --user将下载的包保存在当前用户目录中(因此您不需要更多权限)。

    • package_name任何 Python 包。

    编辑:
    1. 为 Python 和 ssl 安装必要的包:sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

    1. 从https://www.python.org/ftp/python/下载“Python-3.7.0.tar.xz”并将其解压缩到您的主目录中。

    2. 在该目录中打开终端并运行:./configure

    3. 构建和安装:sudo make && sudo make install

    4. 安装软件包:pip3 install package_name

    • 11

相关问题

  • 运行打印命令时出现 Python 3 错误

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve