1

I know, the question may seem easy but believe me you don't know the whole story.

I'm running Ubuntu 14.04.

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

I installed a newer python version (3.8) because I wanted to install Discord.py

$ python3.8 -V
Python 3.8.2

When I try installing pip using the steps bellow I get these errors:

$ 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

Oh, yeah... I tried installing pip with the original python3 installation and that was successful but...

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

But on trying to install 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

I've searched everywhere trying to find a solution for the past two days and it's driving me crazy! At first I thought I just needed to install the python ssl module to install pip on python3.8, but then to do that pip was required in the first place, that's when I gave up. I'm open to suggestions, please help me out!

This is what happened when I tried installing Discord.py using python3.6:

$ 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'
Sujit
  • 1,653
  • 2
  • 9
  • 25
  • Did you try `python3.8 -m pip install -U discord.py`? – Zionsof Apr 05 '20 at 14:06
  • @Zionsof for that I need pip first. – Sujit Apr 05 '20 at 14:06
  • You said you installed with python3 installation, what did you run? Why can't you try the same for python3.8? – Zionsof Apr 05 '20 at 14:33
  • @Zionsof, I tried it with the python3 installation as well by running `python3 -m pip install -U discord.py`, it gave the errors I've already mentioned above. – Sujit Apr 05 '20 at 14:46
  • @Zionsof, while trying to install pip using python3.8, it failed. – Sujit Apr 05 '20 at 14:47
  • I meant, how did you install `pip` in `python3`? – Zionsof Apr 05 '20 at 14:50
  • @Zionsof `sudo apt-get install python3-pip`. Why it installed 1.5.4, I have no clue. I guess the versions after that required the ssl module or something. – Sujit Apr 05 '20 at 14:54
  • First, take a look at [this thread](https://askubuntu.com/questions/1187358/pip-for-python-3-8), and maybe try `sudo apt-get install python3.8-pip` if you haven't before. It seems that thread might of be of help to you – Zionsof Apr 05 '20 at 15:13
  • How did you install Python 3.8? `pip` is bundled with Python since 3.5. What does `python3.8 -m pip --version` return? – hoefling Apr 05 '20 at 15:14
  • @hoefling that returns `pip 19.2.3 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)`. Weird, i thought it gave an error. – Sujit Apr 05 '20 at 15:33
  • @Zionsof when I run `python3.8 -m pip install -U discord.py`, it gives the same error as python3 – Sujit Apr 05 '20 at 15:36
  • What does `openssl version` return? – hoefling Apr 05 '20 at 15:37
  • @hoefling that returns `OpenSSL 1.0.1f 6 Jan 2014` – Sujit Apr 05 '20 at 15:38
  • If you have built Python 3.8 from source, checkout the `make` log - it should report the failure when trying to build the `_ssl` module, so your Python installation is crippled. Python 3.8 requires OpenSSL at least 1.0.2. You have to download and build OpenSSL from source and then rebuild Python 3.8 linking to custom OpenSSL lib. – hoefling Apr 05 '20 at 15:42
  • @hoefling can you guide me through the OpenSSL installation? Maybe add it as an answer? – Sujit Apr 05 '20 at 15:49
  • @hoefling would python3.6 work? – Sujit Apr 05 '20 at 15:52
  • Check out [this question](https://stackoverflow.com/q/5937337/2650249) for step-by-step tutorials. Python 3.6 will work with OpenSSL provided by trusty, although 3.6 deprecated 1.0.1. – hoefling Apr 05 '20 at 16:05
  • @hoefling so I installed python3.6 and tried installing Discord, I ran into a small error that I will update in the question. – Sujit Apr 05 '20 at 16:49
  • Run `python3.6 -m pip --upgrade pip` first, then try reinstalling. – hoefling Apr 05 '20 at 16:53
  • @hoefling I'm getting similar errors – Sujit Apr 05 '20 at 16:58
  • @hoefling alright, I noticed a bunch of PermissionErrors and added `sudo` at the beginning... It worked! Thanks a lot for your help. If you somehow put all of this into an answer, I'd be happy to accept it. – Sujit Apr 05 '20 at 17:01

1 Answers1

1

Here are the steps to install discord in Ubuntu 14 with Python 3.6:

$ 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
hoefling
  • 59,418
  • 12
  • 147
  • 194