Pycharm does not use PATH settings for conda environment

Answered

I am having some troubles using PyCharm after some recent updates (exactly which ones I am no longer sure), that all involve the system PATH (not the PYTHONPATH).  I am running on Windows, with a fresh install of Anaconda 2021.05 as a local install (just for me) - although, I am operating a conda environment with just a subset of packages installed.

It started when suddenly I could not import numpy due to a DLL import error.  According to my searches on the internet, I had to add the Library\bin folder from my Anaconda3 installation to my PATH variable (which worked, but I've never had to do before). I have left that there, even though I don't like it, but then I started having problems with similar things with other packages.  Everything works with no issues at all if it is run from an Anaconda command prompt (not involving PyCharm).  But running scratches that way (for example) is really really frustrating.

Here is what I get when I examine the PATH in the aforementioned command prompt when the py_utils environment is active:

(py_utils) C:\>for %a in ("%path:;=";"%") do @echo %~a
C:\Users\asmith\Anaconda3\envs\py_utils
C:\Users\asmith\Anaconda3\envs\py_utils\Library\mingw-w64\bin
C:\Users\asmith\Anaconda3\envs\py_utils\Library\usr\bin
C:\Users\asmith\Anaconda3\envs\py_utils\Library\bin
C:\Users\asmith\Anaconda3\envs\py_utils\Scripts
C:\Users\asmith\Anaconda3\envs\py_utils\bin
C:\Users\asmith\Anaconda3\condabin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\libnvvp
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0
C:\Windows\CCM
C:\Windows\CCM
C:\Windows\CCM
C:\Windows\CCM
C:\Windows\CCM
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit
C:\Program Files\Microsoft SQL Server\110\Tools\Binn
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0
C:\Program Files\Microsoft SQL Server\120\Tools\Binn
C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn
C:\Program Files\TortoiseHg
C:\Program Files\TortoiseSVN\bin
C:\Program Files\TortoiseGit\bin
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Users\asmith\AppData\Local\Microsoft\WindowsApps
C:\Users\asmith\AppData\Local\LyX 2.3\Perl\bin
C:\Users\asmith\AppData\Local\Programs\Git\mingw64\bin
C:\Users\asmith\MinGW\bin
C:\Users\asmith\Documents\PortablePrograms\CMake\bin
C:\Users\asmith\AppData\Local\Programs\Microsoft VS Code\bin
C:\Users\asmith\Anaconda3\Library\bin
C:\Users\asmith\AppData\Local\Programs\MiKTeX\miktex\bin\x64

The block at the bottom contains my local environment settings for PATH - the block at the top is clearly the Anaconda prompt adding its set of directories to the PATH.

I have a python_utils project in PyCharm, for which I am using the py_utils conda environment.  But when I examine the PATH in a Python console, this is all I get:

In[2]: import os
In[3]: os.getenv('PATH').split(';')
Out[3]:
['C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.1\\bin',
'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.1\\libnvvp',
'C:\\Windows\\system32',
'C:\\Windows',
'C:\\Windows\\System32\\Wbem',
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\',
'C:\\Windows\\CCM',
'C:\\Windows\\CCM',
'C:\\Windows\\CCM',
'C:\\Windows\\CCM',
'C:\\Windows\\CCM',
'C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\',
'C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\',
'C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.0\\',
'C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\',
'C:\\Program Files (x86)\\Microsoft SQL Server\\90\\Tools\\binn\\',
'C:\\Program Files\\TortoiseHg\\',
'C:\\Program Files\\TortoiseSVN\\bin',
'C:\\Program Files\\TortoiseGit\\bin',
'C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common',
'C:\\Users\\asmith\\AppData\\Local\\Microsoft\\WindowsApps',
'C:\\Users\\asmith\\AppData\\Local\\LyX 2.3\\Perl\\bin',
'C:\\Users\\asmith\\AppData\\Local\\Programs\\Git\\mingw64\\bin',
'C:\\Users\\asmith\\MinGW\\bin',
'C:\\Users\\asmith\\Documents\\PortablePrograms\\CMake\\bin',
'C:\\Users\\asmith\\AppData\\Local\\Programs\\Microsoft VS Code\\bin',
'C:\\Users\\asmith\\Anaconda3\\Library\\bin',
'C:\\Users\\asmith\\AppData\\Local\\Programs\\MiKTeX\\miktex\\bin\\x64']

Notice that the whole block at the top with C:\Users\asmith\Anaconda3\envs\py_utils is missing, and a whole host of things apparently need that to be there (numpy, pyqt, cartopy).  Note that the PYTHONPATH settings for the environment work just fine ... I get OSErrors related to DLLs, not ModuleNotFound errors.

I very very much do NOT want to have Anaconda permanently in my PATH.  I have diligently searched but I too often find people's issues with the PYTHONPATH, not the system PATH.  The closest thing I have found is this unanswered post: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000643679-Use-environment-variables-from-conda-environment?input_string=Pycharm%20system%20PATH%20does%20use%20conda%20environment

I used to not have any problems with this.  What changed to make PyCharm not find the appropriate PATH so that DLLs can be found?  How do I fix this?

1
3 comments

Has this been solved?

0

I just ran into this thread because I ran into this problem with latest PyCharm in August 2026

0

Two different causes produce this missing-PATH symptom, and both appear in this thread.

The original 2021 report was tracked as PY-51551. The cause there was that the base conda installation had never been initialized. The Anaconda Prompt printed "The system cannot find the path specified", and the reporter found that running conda init in that prompt also restored PyCharm's ability to activate the environment. That is worth trying first, because conda init fixes the cause rather than working around it.

PyCharm 2026.2.x has a second, unrelated bug. Conda activation is not applied to the launched process at all. No conda directory reaches PATH and CONDA_PREFIX stays empty, so anything that loads a DLL from <env>\Library\bin fails. This is PY-91371, and the fix is merged for PyCharm 2026.3. The Python Console builds its process through the same code, so it is affected in the same way.

Until 2026.3, add the conda directories to PATH in the environment variables of the run or debug configuration:

PATH=<env>;<env>\Library\bin;<env>\Library\usr\bin;<env>\Scripts;%PATH%

Code that reads conda's own variables also needs CONDA_PREFIX, CONDA_DEFAULT_ENV and CONDA_SHLVL.

0

Please sign in to leave a comment.