I'm experiencing an import failure, which I believe is due to my import "stack" taking a slight detour away from my minconda3
virtual environment and into my system Python installation:
Traceback (most recent call last):
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\enable\qt4\base_window.py", line 255, in paintEvent
self.handler.paintEvent(event)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\enable\qt4\base_window.py", line 90, in paintEvent
self._enable_window._paint(event)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\enable\abstract_window.py", line 536, in _paint
self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\enable\component.py", line 410, in draw
self._draw(gc, view_bounds, mode)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\enable\component.py", line 791, in _draw
self._dispatch_draw(layer, gc, view_bounds, mode)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\enable\container.py", line 270, in _dispatch_draw
component._dispatch_draw(layer, gc, new_bounds, mode)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\enable\container.py", line 270, in _dispatch_draw
component._dispatch_draw(layer, gc, new_bounds, mode)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\enable\component.py", line 809, in _dispatch_draw
handler(gc, view_bounds, mode)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\chaco\base_2d_plot.py", line 221, in _draw_image
self._render(gc)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\chaco\plots\cmap_image_plot.py", line 101, in _render
ImagePlot._render(self, gc)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\chaco\plots\image_plot.py", line 165, in _render
gc.draw_image(self._cached_image, self._cached_dest_rect)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\kiva\agg\agg.py", line 1216, in draw_image
from PIL import Image
File "C:\Users\capnf\AppData\Roaming\Python\Python39\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
return original_import(name, *args, **kwargs)
File "C:\Users\capnf\AppData\Roaming\Python\Python39\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
return original_import(name, *args, **kwargs)
File "C:\Users\capnf\miniconda3\envs\pybert-tst\lib\site-packages\PIL\Image.py", line 100, in <module>
from . import _imaging as core
File "C:\Users\capnf\AppData\Roaming\Python\Python39\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
return original_import(name, *args, **kwargs)
File "C:\Users\capnf\AppData\Roaming\Python\Python39\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
return original_import(name, *args, **kwargs)
ImportError: DLL load failed while importing _imaging: The specified module could not be found.
In troubleshooting this, I find that my system Python installation's site-packages/
folder appears before that of my conda
virtual environment, despite the fact that all other paths related to my virtual environment appear before my system path entry!:
(base)
capnf@DESKTOP-G84ND7C MINGW64 ~
$ conda activate pybert-tst
(pybert-tst)
capnf@DESKTOP-G84ND7C MINGW64 ~
$ python -c "import sys; print(sys.path)"
[ ''
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst\\python39.zip'
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst\\DLLs'
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst\\lib'
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst'
, 'C:\\Users\\capnf\\AppData\\Roaming\\Python\\Python39\\site-packages'
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst\\lib\\site-packages'
]
What is the reason for doing it this way?
System Info:
Windows 11 Home
Miniconda3:
Python 3.9
conda
v23.1.0
Follow-on Sleuthing Results
Aha! After completely removing my AppData/Roaming/Python/
folder, the offending entry in my Python search path is now absent upon reactivating my pybert-tst
virtual environment:
(base)
capnf@DESKTOP-G84ND7C MINGW64 ~
$ conda activate pybert-tst
(pybert-tst)
capnf@DESKTOP-G84ND7C MINGW64 ~
$ python -c "import sys; print(sys.path)"
[ ''
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst\\python39.zip'
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst\\DLLs'
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst\\lib'
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst'
, 'C:\\Users\\capnf\\miniconda3\\envs\\pybert-tst\\lib\\site-packages'
]
So, maybe, the construction of the new Python search path upon activation of a conda
virtual environment is performed dynamically and programmatically, as opposed to just being an amalgam of certain static entities (i.e. - environment variables, etc.)?
If so, where is this assemblage performed?