0

I created venvs for couple diff projects using python3 -m venv my_project Also use pyenv local version for managing the python version for each project as needed.

My projects folder looks like this:

my-project-one/
my-project-two/
my_project_one/
my_project_two/

The ones with hypens are the repo while the ones with underscores are the venv I create for them. (maybe stupid naming scheme but works for me).

I activate the venv with source ../my_project_one/bin/activate from within the one I want to work with.


It has been great since I was using VSCode. Now I want to use Pycharm and I can't figure out how to make venv work with Pycharm.

In the project interpreter section I can see the two versions under ~/.pyenv/versions/ but that doesn't detect the project dependent requirements I have installed on the venv.

Many articles mentions about adding the python executable unders Scripts folder in venv but there is no such folder in any of mine. (on MacOS)


What am I missing here? Did I create the venv incorrectly or following the instruction for the wrong implementation of virtual env because I really don't want to mess with a working setup just for Pycharm.


I hope it would at the very least detect the project level libraries and not show unresolved reference for them.

BharathYes
  • 787
  • 2
  • 9
  • 25
  • Are you sure there's no `python.` or `python.exe` in the venv's bin folder? – bad_coder Jul 31 '21 at 20:22
  • @bad_coder coundn't find any executables. Under bin found two alias named `python` and `python3` linked to another bin location on home but unable to make use of them on pycharm in any way. – BharathYes Aug 02 '21 at 04:32
  • That's really strange, when I run the same command on Windows the venv is created with an executable. I suppose pyenv is what's causing that there's a link instead of an executable. And apparently the problem is PyCharm only identifies executabls as interpreters not links. – bad_coder Aug 02 '21 at 05:21
  • There are only [10 questions with the pycharm + pyenv tags](https://stackoverflow.com/questions/tagged/pyenv+pycharm). In [this question](https://stackoverflow.com/q/66110150) it seems to suggest you need to use an additional step of activating by using `pyenv activate` try to using that and afterwards see if the PyCharm can detect the interpreter. If you're really stuck just create a plain venv without pyenv... – bad_coder Aug 02 '21 at 05:25
  • Am not sure if `pyenv activate` is required in my case. I only use it to use a specific version 3.6.9/3.7.11 for my project which I have set at a directory level like `pyenv local 3.7.11`. And PyCharm does properly detect this and uses the correct python interpreter version as set for both projects using pyenv. My issue is that the project specific libraries I have installed on venv is not detected and pycharm asks me to install them. – BharathYes Aug 02 '21 at 13:21

0 Answers0