如何使用本地python安装在ubuntu 14.04上安装pip

问题描述 投票:0回答:1

我知道,这个问题似乎很简单,但请相信我,您不了解整个故事。

我正在运行Ubuntu 14.04。

$ python -V
Python 2.7.6
$ python3 -V
Python 3.4.3

我安装了较新的python版本(3.8),因为我想安装Discord.py

$ python3.8 -V
Python 3.8.2

当我尝试使用下面的步骤安装pip时,出现以下错误:

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1764k  100 1764k    0     0  1351k      0  0:00:01  0:00:01 --:--:-- 1363k
$ python3.8 get-pip.py
Defaulting to user installation because normal site-packages is not writeable
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: 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/pip/
WARNING: Retrying (Retry(total=3, 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/pip/
WARNING: Retrying (Retry(total=2, 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/pip/
WARNING: Retrying (Retry(total=1, 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/pip/
WARNING: Retrying (Retry(total=0, 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/pip/
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
ERROR: Could not find a version that satisfies the requirement pip (from versions: none)
ERROR: No matching distribution found for pip
WARNING: 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

哦,是的...我尝试使用原始的python3安装来安装pip,但成功了,但是...

$ pip3 -V
pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)

但是尝试安装Discord.py时:

$ python3 -m pip install -U discord.py
Downloading/unpacking discord.py
  Downloading discord.py-1.3.3-py3-none-any.whl (676kB): 676kB downloaded
Downloading/unpacking websockets>=6.0,!=7.0,!=8.0,!=8.0.1,<9.0 (from discord.py)
  Downloading websockets-8.1.tar.gz (58kB): 58kB downloaded
  Running setup.py (path:/tmp/pip_build_sujit/websockets/setup.py) egg_info for package websockets
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_sujit/websockets/setup.py", line 12, in <module>
        long_description = (root_dir / 'README.rst').read_text(encoding='utf-8')
    AttributeError: 'PosixPath' object has no attribute 'read_text'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_sujit/websockets/setup.py", line 12, in <module>

    long_description = (root_dir / 'README.rst').read_text(encoding='utf-8')

AttributeError: 'PosixPath' object has no attribute 'read_text'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_sujit/websockets
Storing debug log for failure in /home/sujit/.pip/pip.log

过去两天,我到处搜索以寻找解决方案,这让我发疯了!起初我以为我只需要安装python ssl模块就可以在python3.8上安装pip,但是首先要做到这一点,那就是我放弃了。我愿意接受建议,请帮帮我!

这是当我尝试使用python3.6安装Discord.py时发生的事情:

$ python3.6 -m pip --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
sujit@sujit-MXC061:/opt/Python-3.6.3$ python3.6 -m pip install -U discord.py
Collecting discord.py
  Downloading https://files.pythonhosted.org/packages/f6/12/a3cfceefd625c39a2d6f9f52ffad57f1b3fcb9906eaa0eeafd2392f10deb/discord.py-1.3.3-py3-none-any.whl (676kB)
    100% |████████████████████████████████| 686kB 282kB/s 
Collecting websockets!=7.0,!=8.0,!=8.0.1,<9.0,>=6.0 (from discord.py)
  Downloading https://files.pythonhosted.org/packages/c8/34/947fff38511d40daa350f63a1b1a972767c90a30c0f6115a622642b48a4d/websockets-8.1-cp36-cp36m-manylinux1_i686.whl (72kB)
    100% |████████████████████████████████| 81kB 1.4MB/s 
Collecting aiohttp<3.7.0,>=3.6.0 (from discord.py)
  Downloading https://files.pythonhosted.org/packages/c2/f7/f0ad3dbace4762fef5d80aa4124b41bf218e4c4dd6d387a86cede707d9a4/aiohttp-3.6.2-py3-none-any.whl (441kB)
    100% |████████████████████████████████| 450kB 346kB/s 
Collecting attrs>=17.3.0 (from aiohttp<3.7.0,>=3.6.0->discord.py)
  Downloading https://files.pythonhosted.org/packages/a2/db/4313ab3be961f7a763066401fb77f7748373b6094076ae2bda2806988af6/attrs-19.3.0-py2.py3-none-any.whl
Collecting typing-extensions>=3.6.5; python_version < "3.7" (from aiohttp<3.7.0,>=3.6.0->discord.py)
  Downloading https://files.pythonhosted.org/packages/0c/0e/3f026d0645d699e7320b59952146d56ad7c374e9cd72cd16e7c74e657a0f/typing_extensions-3.7.4.2-py3-none-any.whl
Collecting async-timeout<4.0,>=3.0 (from aiohttp<3.7.0,>=3.6.0->discord.py)
  Downloading https://files.pythonhosted.org/packages/e1/1e/5a4441be21b0726c4464f3f23c8b19628372f606755a9d2e46c187e65ec4/async_timeout-3.0.1-py3-none-any.whl
Collecting yarl<2.0,>=1.0 (from aiohttp<3.7.0,>=3.6.0->discord.py)
  Downloading https://files.pythonhosted.org/packages/d6/67/6e2507586eb1cfa6d55540845b0cd05b4b77c414f6bca8b00b45483b976e/yarl-1.4.2.tar.gz (163kB)
    100% |████████████████████████████████| 163kB 550kB/s 
Collecting multidict<5.0,>=4.5 (from aiohttp<3.7.0,>=3.6.0->discord.py)
  Downloading https://files.pythonhosted.org/packages/61/b4/475114b3f1671da634f89239e61038f8742d9ac13aa34b32a05bf8022d22/multidict-4.7.5.tar.gz (50kB)
    100% |████████████████████████████████| 51kB 756kB/s 
Collecting chardet<4.0,>=2.0 (from aiohttp<3.7.0,>=3.6.0->discord.py)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 709kB/s 
Collecting idna-ssl>=1.0; python_version < "3.7" (from aiohttp<3.7.0,>=3.6.0->discord.py)
  Downloading https://files.pythonhosted.org/packages/46/03/07c4894aae38b0de52b52586b24bf189bb83e4ddabfe2e2c8f2419eec6f4/idna-ssl-1.1.0.tar.gz
Collecting idna>=2.0 (from yarl<2.0,>=1.0->aiohttp<3.7.0,>=3.6.0->discord.py)
  Downloading https://files.pythonhosted.org/packages/89/e3/afebe61c546d18fb1709a61bee788254b40e736cff7271c7de5de2dc4128/idna-2.9-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 1.4MB/s 
Installing collected packages: websockets, attrs, typing-extensions, async-timeout, multidict, idna, yarl, chardet, idna-ssl, aiohttp, discord.py
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/usr/local/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/local/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/site-packages/websockets-8.1.dist-info'
python-3.x pip discord.py discord.py-rewrite
1个回答
0
投票

以下是在具有Python 3.6的Ubuntu 14中安装discord的步骤:

$ docker pull ubuntu:trusty
$ docker run -it ubuntu:trusty
# apt update
# apt install -y build-essential checkinstall libreadline-gplv2-dev \
    libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev \
    libbz2-dev libffi-dev zlib1g-dev wget
# cd /opt
# wget https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tgz
# tar xzv Python-3.6.10.tgz && cd Python-3.6.10
# ./configure --enable-optimizations
# make altinstall
# python3.6 -m pip install --upgrade pip
# python3.6 -m pip install discord
# python3.6 -c "import discord; print(discord.__version__)"
1.3.3
© www.soinside.com 2019 - 2024. All rights reserved.