Discord Bot on Raspberry Pi: Python Version Mismatch with Pip

I’m trying to set up a Discord bot on my Raspberry Pi so it can run 24/7. The bot is written in Python, but I’m running into issues with the Python version and pip.

When I try to run the bot, I get an error saying no module named discord. I’ve tried to install it using pip3 install discord, but it installs under Python 3.4 instead of 3.5, which I need.

I’ve also tried python3 -m pip install discord, but I get an error saying /usr/local/bin/python3: No module named pip.

When I check the pip version with pip -V, it shows 3.4. I’ve even tried running the get-pip.py file, but I’m still stuck with pip 3.4.

How can I update pip to work with Python 3.5 on my Raspberry Pi? I’m really stuck and could use some help!

I ran into a similar issue when setting up a Discord bot on my Pi. Here’s what worked for me:

First, make sure you have Python 3.5 installed. You can check with ‘python3 --version’. If it’s not there, you might need to add the deadsnakes PPA and install it.

Then, I’d recommend creating a virtual environment specifically for your bot. This keeps dependencies isolated:

python3.5 -m venv bot_env
source bot_env/bin/activate

Now, within this environment, upgrade pip:

python -m pip install --upgrade pip

After that, you should be able to install discord.py:

pip install discord.py

This approach solved the version mismatch for me and got everything working smoothly. Hope it helps!

yo, ive been there. wat helped me was usin python3.5-venv to make a virtual environment. then activate it and install discord with pip. like this:

python3.5 -m venv mybot_env
source mybot_env/bin/activate
pip install discord

shud work without the version headache. good luck man!

Have you considered using pyenv to manage Python versions? It’s a lifesaver for situations like this. Install pyenv, then use it to install Python 3.5 alongside your system Python. You can then create a pyenv virtualenv for your bot project:

pyenv install 3.5.10
pyenv virtualenv 3.5.10 discord_bot
pyenv local discord_bot

This sets up an isolated environment with Python 3.5 and its own pip. From there, just ‘pip install discord’ and you should be good to go. It’s a bit more setup initially, but it makes managing different Python versions and projects much easier in the long run.