Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PYCHARM professonal with WSL2 as python interpreter: does not have access to some packages

I have python working on WSL2 along with ubuntu20.04. I then installed miniconda and then, also installed all common data package, such as: tensorflow, pandas, scikit-learn, matplotlib, sqlalchemy, seaborn pip git

Everything is working fine.

I also have PYCHARM professional installed and as a python interpreter, I am using WSL2(ubuntu20.04). When I try to run the same code that rans fine from WSL2 terminal, PYCHARM complains about unresolved reference to "sklearn" and offers to download that package. Two questions:

i. Should not PYCHARM has access to whatever packages are available from WSL2/Ubuntu20.04 terminal, as I am using WSL2 as the PYTHON interpreter?

ii. If I let PYCHARM download package regardless, would not it create duplicate packages that could be possibly different versions?

# import the necessary packages
from sklearn.neighbors import KNeighborsClassifier
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report

I am also attaching python interpreter screenshot to show that I a doing it correctly.enter image description here

UPDATE: based on @batuhand suggestion, I would like to try using the virtual enviroment. However, the problem is that WSL interpreter is not available.

When I choose WSL interpreter, then \usr\bin\python3 is available. enter image description here

When I choose virtual environment, \usr\bin\python is not available. enter image description here

So, it seems that I can not follow @batuhand 's suggestion.

like image 396
Garima Singh Avatar asked Oct 15 '25 22:10

Garima Singh


1 Answers

Thanks @PavelKarateev. He pointed out to me on JetBrains.com that my interpreter was pointing to /usr/bin/python3 and I have point it to current location. This in my case is:

wsl://UBUNTU2004/home/$USER/miniconda3/envs/PipInConda_DKU/bin/python3.

Here "PipInConda_DKU" was the virtual environment that I created inside the Conda. As the name suggest, I was also using pip to install some package from Anaconda.

like image 187
Garima Singh Avatar answered Oct 18 '25 11:10

Garima Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!