I'm trying to use a Python interpreter in WSL to make virtual environments, buy it doesn't show any Python file.
I used where python3
to find the interpreter. It says /usr/bin/python3
but as you can see it shows nothing in PyCharm.
I also tried uninstalling and reinstalling PyCharm and it didn't work.
Also when I create a virtual env from WSL terminal using virtualenv -p python3 venv
I can't import that in PyCharm because it doesn't recognize Python in ~/venv/bin/...
If you have any directory with some Python files in \\wsl$ , you can open this directory in PyCharm. The IDE will create a project and suggest creating a WSL-based interpreter.
Set an existing virtual environmentPress Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. icon and select Show All. Select the target environment from the list and click OK to confirm your choice.
Sadly, Virtual Environments are not yet supported in Pycharm with WSL. See the docs here. Excerpt: "Note that with WSL you cannot create virtual environments: all packages you install will be added to the corresponding system interpreter. You will be asked to enter your sudo password"
Also when I create a virtual env from WSL terminal using virtualenv -p python3 venv I can't import that in PyCharm because it doesn't recognize Python in ~/venv/bin/... Show activity on this post. Sadly, Virtual Environments are not yet supported in Pycharm with WSL. See the docs here.
With my experience I know PyCharm doesn't support creating a new venv environment from the IDE on the remote server. The workaround I use is to first set up new venv manually within the server, and then when I set up the project interpreter in PyCharm I set the interpreter path to the relevant venv path in the server.
If PyCharm warns you about an Invalid environment, the specified Python binary cannot be found in the file system, or the Python version is not supported. Check the Python path and install a new version, if needed. You can create as many virtual environments as required. To easily tell them from each other, use different names.
You can set up venv inside wsl:
python3 -m venv /usr/venv/project1
And add this to pycharm:
Sadly, Virtual Environments are not yet supported in Pycharm with WSL. See the docs here.
Excerpt: "Note that with WSL you cannot create virtual environments: all packages you install will be added to the corresponding system interpreter. You will be asked to enter your sudo password"
If I absolutely need to code against a library within Ubuntu (such as Apache Pulsar), I use Linux Pycharm running an XSession to XFCE, running withing WSL. It works very well and you will find lots of articles to achieve this with a Google Search.
I am not familiar with using WSL through PyCharm, but I do use an interpreter on remote server thourgh SSH.
With my experience I know PyCharm doesn't support creating a new venv
environment from the IDE on the remote server.
The workaround I use is to first set up new venv
manually within the server, and then when I set up the project interpreter in PyCharm I set the interpreter path to the relevant venv
path in the server.
So I suggest the same thing- first create a new venv
on the WSL environment and then set the path of the venv
as the project interpreter (through WSL no through remote server)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With