0

I'm working on a discord bot using the discord.

The bot works using the command python3.5 bot.py.

I'm unable to find out why discord isn't recognized by 3.10.4. I'd really like this to work on at least Python 3.6 as I'm attempting to import some other modules that use f strings.

I'm specifically having issues with the first line of the code:

import discord

For context, here's what returns running my python versions:

$ python -V
bash: python: command not found
$ python3 -V
Python 3.10.4
$ python3.5 -V
Python 3.5.3
$ python3.10 -V
Python 3.10.4

As mentioned previously the bot works using the command python3.5 bot.py but here are all the other errors:

$ python bot.py
bash: python: command not found
$ python3 bot.py
Traceback (most recent call last):
  File "/home/pi/Desktop/Bot/bot.py", line 1, in <module>
    import discord
ModuleNotFoundError: No module named 'discord'
$ python3.10 bot.py
Traceback (most recent call last):
  File "/home/pi/Desktop/Bot/bot.py", line 1, in <module>
    import discord
ModuleNotFoundError: No module named 'discord'

I am also working on a Raspberry Pi 3 B+.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.13 (stretch)
Release:    9.13
Codename:   stretch

UPDATE: Random Davis Has helped in identifying that both my pip and pip3 were out of date (pip 20.3.4 python 3.5). Davis offered a link that allowed you to run pip with a specific version using python3 -m pip revealing great results of (pip 22.0.4 python 3.10).

However there exists some issues installing discord.py using python3 -m pip install discord.py. Seems to be some SSL Error. The full error is listed below:

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.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
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/discord-py/
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/discord-py/
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/discord-py/
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/discord-py/
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/discord-py/
Could not fetch URL https://pypi.org/simple/discord-py/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/discord-py/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
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/discord-py/
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/discord-py/
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/discord-py/
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/discord-py/
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/discord-py/
Could not fetch URL https://www.piwheels.org/simple/discord-py/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='www.piwheels.org', port=443): Max retries exceeded with url: /simple/discord-py/ (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 discord.py (from versions: none)
ERROR: No matching distribution found for discord.py
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
Could not fetch URL https://www.piwheels.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='www.piwheels.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

I tried searching for some things and tried python3 -m pip install --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --trusted-host=piwheels.org discord producing similar results.

lime
  • 801
  • 8
  • 21
  • 1
    You're describing how you're *running* your code but not how you're *installing* the module. You're installing it into one specific Python environment, seemingly, that being your 3.5 environment. I would think that you'd have to specify which version you're installing a module for, and also that a module installed in one Python environment won't necessarily be accessible to another one. – Random Davis May 05 '22 at 18:23
  • @RandomDavis I see. I've checked my pip versions (assuming this might be the issue as I've installed them using `pip install discord`). When running `pip -V` and `pip3 -V` they both return `pip 20.3.4 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)`. This must mean it's installing the 3.5 version regardless of whether I'm using `pip` or `pip3` right? – lime May 05 '22 at 18:41
  • 1
    Yes. If you want a specific version, try `python3.9/8/7/whatever -m pip args` – Eric Jin May 05 '22 at 19:29
  • @lime certainly. Here's a simple solution I found: https://askubuntu.com/questions/1223290/pip3-is-pointing-to-the-wrong-version-of-python – Random Davis May 05 '22 at 19:31
  • @RandomDavis Thanks. I've updated the question regarding the post you've sent me. It seems there's been some headway in terms of pip but I'm blocked again if you have any other ideas. It's not my first time running into this error. It happens almost every time I installed something using python3 – lime May 05 '22 at 20:40
  • Searching for `WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available` I found [this post](https://stackoverflow.com/questions/45954528/pip-is-configured-with-locations-that-require-tls-ssl-however-the-ssl-module-in), you didn't mention trying any of those solutions so I'm wondering if that helps. – Random Davis May 05 '22 at 20:44

0 Answers0