0

Edit: It's working fine now, it seems there was just something weird going on with VSCode

I am writing a discord bot in Python using Gitpod (which has VSCode Browser as its editor). I have installed Pycord 2.0 in the workspace using pip (obviously) but VSCode doesn't seem to be recognising it. I also have the Python VSCode extension installed which adds a 'Run' to the editor when a python file is selected. It used to work just fine but since a month ago it stopped working and the 'Run Code' button is running some sort of Python installation where none of the modules I installed are there. It also doesn't show any code hints for the modules.

I have tried pip show py-cord and changing the selected VSCode python interpreter accordingly. I've also tried changing th interpreter and installing Pycord into that interpreter but none of that worked. I am running Gitpod on an iPad 6 (model A1893, iPadOS 15.6.1) in Safari

Does anyone know what might be wrong?

Thanks :)

~ R2509

2 Answers2

0

Many developers have multiple python versions installed, and multiple environments with the same python versions, but different libraries installed. Therefore, we need to specify which python compiler VSCode needs to use.

Check on the bottom right of your VSCode, there should be a number down there representing an installation of python.

Python version

Upon clicking on it, VSCode will open a window on the top part, allowing you to select which of the many pythons you have installed you want to use. Find the one where you installed your libraries, and you should be good to go.

Gabriel d'Agosto
  • 416
  • 3
  • 12
  • Thanks. How do I know which installation of Python I have installed all the libraries into? I have a script which installs and runs python 3.10.2 and then runs pip on a requirements file. Does that mean that the modules are installed into python 3.10.2? Because if so, VSCode automatically changes the thing on the bottom right to 3.10.2 as well, but it still doesn't work –  Aug 24 '22 at 21:59
0

Method one:

  • Use pip show Pycord to see where you installed the package Pycord

    enter image description here

  • then choose that environment

Method Two:

  • Choose a python version you want to use ( Ctrl+Shift+P --> Python:Select Interpreter )

    enter image description here

  • Create a new terminal activation environment

    enter image description here

  • Install the package using pip install pycord in the new terminal

    enter image description here

As a suggestion:

you can use a virtual environment to better manage python versions and various packages.

# Create a virtual environment named .venv
python -m venv .venv

# Activate this virtual environment
.venv\scripts\activate
JialeDu
  • 6,021
  • 2
  • 5
  • 24
  • I've tried all the things you said but for some reason it *still* won't work (I think it might be an issue with Gitpod or something) It just gives me a `ModuleNotFoundError` –  Aug 25 '22 at 08:15
  • Can you update your answer to show these misinformation of yours? And information such as `pip show pycord` and your installed python environment. – JialeDu Aug 25 '22 at 08:28
  • Okay --------------- –  Aug 25 '22 at 08:55