简体   繁体   中英

IntelliJ idea resolving python venv depenency

In my project I have

import datetime as dt

Which can not be resolved in IntelliJ idea..

I do have requirements.in file

python -m piptools compile --upgrade sergii-requirements.in

and generated requirements.txt with datetime defined there

python -m piptools sync requirements.txt

These dependencies are set in my activated virtual environment ( venv folder)

yet, I am not sure how to make IntelliJ idea aware of that venv. and my dependencies and make it resolved? (not that intuitive.. for java dev..)

UPDATE : I did try it in PyCharm , it did work as soon as I set:

Project SKD to /home/user/projects/my-project/venv/bin/python3.9 - it did resolve everything.

Same thing did not & have not yet worked in IntellJ Idea.. (2021.1)

Update 2:

BUT: how do I know that resolved depenency is from my venv. Seems it is not.

Ok. The reason is. My python plugin had an issue. I had to upgrade it to the latest intelli idea version, to be compatible.

Hope it will save someone's time once googled for this issue.

--

yet.. is not nessesary the answer. how do I know that choosing the python SDK in my env actually uses my venv dependencies - from venv and not.

I did remove all from venv. And Idea still resolves datetime . (it is getting from global dependencies)

So please do not consider it as final answer .. not yet.

It did work out though If I remove all other global deps and re-setup my venv env.

Seems, IntellyJ Idea is too intelegent - resolving with everything it could find - from venv and not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM