I was noticing that my import pandas as pd was underlined as well as my other imports and from googling I figured out I merely needed to change my interpreter to the same one my WSL subsystem(ubuntu) was using, which is python 3.8. However, an interpreter file is nowhere in my ubuntu files ( even though I’ve installed python and pandas through the terminal ). There is no .exe file in the bin, nor in any other folder. There is a python3.8 file, but it is a .8 file extension, not a .exe, there are no .exe files in my ubuntu subsystem on my device, even though it should be where pandas and such are installed. There are some on my windows, but none of them are 3.8 and I could just install python 3.8 on windows (not ubuntu as i already have it installed), however I can’t install packages from there using my ubuntu terminal on vs code. I really wish there were a python.exe interpreter on ubuntu but there is not, so my question is how do I change my VS code interpreter to find my python interpreter.
Here is some info:
python3: /usr/bin/python3 /usr/bin/python3.8 /usr/bin/python3.8-config /usr/lib/python3 /usr/lib/python3.8 /usr/lib/python3.9 /etc/python3 /etc/python3.8 /usr/local/lib/python3.8 /usr/include/python3.8 /usr/share/python3 /mnt/c/Users/nuucr/AppData/Local/Programs/Python/Python36/python3.dll /mnt/c/Users/nuucr/AppData/Local/Programs/Python/Python36/python36.dll /mnt/c/Users/nuucr/AppData/Local/Programs/Python/Python310/python3.dll /mnt/c/Users/nuucr/AppData/Local/Programs/Python/Python310/python310.dll /mnt/c/Users/nuucr/AppData/Local/Microsoft/WindowsApps/python3.exe /mnt/c/msys64/mingw64/bin/python3.9-config /mnt/c/msys64/mingw64/bin/python3.exe /usr/share/man/man1/python3.1.gz```
It is in none of the /usrs or /etc directories (which are the ubuntu ones that i need, i need the python3.8 which I know i have from doing the command python3).
I tried looking through the above listed folders and none of the ubuntu folders had any python 3.8 and on windows directories, the only files i did find were not for python 3.8 but other versions
3
Answers
In ubuntu, there is no .exe extension, for example, python3, python, python3.8, somefile.docx can all be programs or executables. In ubuntu, whether a file is an executable (and runnable) is depended on it’s flags. You can see them by typing
ll
into the terminal (under default settings)Changing the interpreters in VS Code
Press
Ctrl + Shift + P
and typePython: Select Interpreters
. You would see a list of interpreters and you can select the one that you need.For example, I have the base Ubuntu python and the anaconda python in the interpreters list. Everytime I create a new environment, that environment gets picked up by VS code and it appears in the list. You can then select the one that applies to your project.
Python environments are awesome because it makes it easier to keep track of all the packages you have installed and share the environment between your collaborators. Usually, people make a new environment everytime they start working on a new project. Anaconda is great with this.
Having said this, if you already have created an environment, it’s really easy to share it with your windows.
Type
explorer.exe
in the terminal and it should open up a window with your wsl files. Copy the requirements file and create the environment in Windows.You need to install the WSL extension and follow this documentation to get started. In addition, it should be noted that there is no
.exe
file in ubuntu, which is normal.There is also a GitHub thread here: https://github.com/microsoft/vscode-python/issues/20839