Reputation: 1927
I have installed python via conda, created a new environment, installed PyCharm and configured it to use this environment.
When I start a python console in PyCharm, I am greeted with a
C:\Users\9973879\AppData\Local\Continuum\miniconda3\envs\foo\lib\site-packages\IPython\core\history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved
Indeed if I try to import sqlite3
, I get a
ImportError: DLL load failed: The specified module could not be found.
However Project Interpreters > Interpreter Paths
does list C:\Users\9973879\AppData\Local\Continuum\miniconda3\envs\foo\{DLLs, Lib, site-packages}
. Also, importing this package from a python interpreter launched from the command line — in that very same virtual environment — succeeds.
EDIT
It seems the problem comes from the PATH
environment variable. When calling conda activate foo
, conda
adds a bunch of folders to the PATH
, containing various libraries (in particular sqlite3.dll
).
When pointing to an existing environment (or creating a new one), PyCharm does automatically add folders to the PYTHONPATH
as pointed out before, but does not seem to add anything to the PATH
.
I tested this assumption by running PyCharm from the command line after calling conda activate foo
, and it works. Of course, having to launch PyCharm from a specific conda environment is not great as I am stuck with this specific environment.
How could PyCharm be configured to automatically update the environment as conda activate
does? Shouldn't it do it straight out of the box?
Upvotes: 5
Views: 6853
Reputation: 12054
I fixed the issue by adding DLL to my < path_to_environment >/DLLs location
Upvotes: 5
Reputation: 1927
The issue seems to be solved by upgrading to the latest 4.6.7 version of conda. The relevant line from the release notes might be
- revert conda prepending to PATH in cli main file on windows (#8307)
I am not sure why it affected PyCharm and not plain python in my case.
Upvotes: 1