Search code examples
macospycharmcondazsh

PyCharm virtual environment is not automatically activated for zsh terminal, MacOS


I have referenced this question: How do I activate a virtualenv inside PyCharm's terminal? As it mentions, PyCharm should support auto activate virtual env since 2016. But I fail to get it work.

setting page of PyCharm Terminal

Above is my setting page for the PyCharm Terminal. I have checked the 'Activate virtualenv'.

PyCharm Terminal

But every time I start a terminal in PyCharm, it didn't automatically activate the virtual env. I need to manually use command conda activate <environment_name> to activate the environment.

I am using a Conda Environment installed with homebrew.

May I ask, is there any parameters that I can add to the Shell path (/bin/zsh) to make it automatically activate specific virtual env? Or other ways to solve this problem?


Solution

  • I have solved this problem with an alternative method found in: https://stackoverflow.com/a/55658404/15416614

    Although this question is originally asking about the Windows environment and it is in 4 years ago, there is an answer from 'Ethan Yanjia Li' that can still solve my current problem.

    This seems to be a PyCharm bug that the 'Activate virtualenv' option is not working sometimes. It has been fixed before but reappears in some situations, according to: https://youtrack.jetbrains.com/issue/PY-23417.