Home > Software design >  Weird version issue with python and VS code
Weird version issue with python and VS code

Time:10-26

-Background- I was having an issue with “import pygame” not working after I updated to python 3.11. So, I thought it was a version issue. VS code says the version is 3.11, but when I typed “python —-version” into my terminal, it said 3.9.12. Why is it showing an older version than I installed?

-What I Tried- To try and find the problem, I deleted python 3.10 because I wasn’t using it, but I couldn’t find 3.9.12 anywhere in my applications or program files. Is there a proper way to locate it or uninstall that version somehow?

CodePudding user response:

You could try which python.

You should also be able to select which python interpreter you want to use in vs code. For me clicking on the version number in the bottom bar of VS code opens up the 'select interpreter' option. You might also use (Ctrl Shift P).

Ultimately, it's a good practice to set up an environment for each project to avoid version conflicts.

CodePudding user response:

To avoid such situations always use python virtualenv.

virtualenv -p python3.9 venv

This command will create virtualenv.

Press shift command p and search for Python: Select Interpreter. this will show the available interpreted in your system. now select venv as the interpreter.

  • Related