I’m puzzled here on few cases:
-
If I start ST normally (double clicking the sublime_text icon) and I query sys.path on the console i’ll get this:
[
‘D:\software\SublimeText 3_x64\Data\Installed Packages\AutoPEP8.sublime-package\sublimeautopep8lib\packages_py3’,
‘D:\software\SublimeText 3_x64’, ‘D:\software\SublimeText 3_x64/python3.3.zip’,
‘D:\software\SublimeText 3_x64\Data\Packages’,
‘D:\software\SUBLIM~2\Data\Packages\shellenv\all’,
‘D:\software\SUBLIM~2\Data\Packages\coverage\ST3_WI~2’,
‘D:\software\SUBLIM~2\Data\Packages\newterm\all’,
‘D:\software\SUBLIM~2\Data\Packages\pyyaml\st3’,
‘D:\software\SublimeText 3_x64\Data\Packages\coverage\st3_windows_x64’
] -
If I run ST from the console after activating python2.7 virtualenv I’ll get the same sys.path output than case 1, so far so good.
-
Now, the problem is when I start sublime text after activating a python3.6.2 virtualenv, where I’ll get this sys.path:
[
‘D:\software\SublimeText 3_x64\Data\Installed Packages\AutoPEP8.sublime-package\sublimeautopep8lib\packages_py3’,
‘D:\software\SublimeText 3_x64’,
‘D:\software\SublimeText 3_x64/python3.3.zip’,
‘D:\software\SublimeText 3_x64\Data\Packages’,
‘D:\software\SUBLIM~2\Data\Packages\shellenv\all’,
‘D:\software\SUBLIM~2\Data\Packages\coverage\ST3_WI~2’,
‘D:\software\SUBLIM~2\Data\Packages\newterm\all’,
‘D:\software\SUBLIM~2\Data\Packages\pyyaml\st3’,
‘D:\software\SublimeText 3_x64\Data\Packages\coverage\st3_windows_x64’,
‘D:\sources\personal\python’,
‘d:\virtual_envs\py362_32\Scripts\python36.zip’,
‘d:\virtual_envs\py362_32\DLLs’,
‘d:\virtual_envs\py362_32\lib’,
‘d:\virtual_envs\py362_32\Scripts’,
‘d:\software\python362_32\Lib’,
‘d:\software\python362_32\DLLs’,
‘d:\virtual_envs\py362_32’,
‘d:\virtual_envs\py362_32\lib\site-packages’,
‘d:\virtual_envs\py362_32\lib\site-packages\win32’,
‘d:\virtual_envs\py362_32\lib\site-packages\win32\lib’,
‘d:\virtual_envs\py362_32\lib\site-packages\Pythonwin’
]
As you can see, sys.path has been extended somehow to include the virtual_env paths and I’d like to understand why… while this is kind of cool, it’ll give visibility to the ST embedded python to the packages of my virtualenv can also be a good way to get unexpected behaviour, for instance, importing pathlib, which it’s just supported by python >= 3.4 would give you something like this:
>>> import pathlib
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "d:\software\python362_32\Lib\pathlib.py", line 382, in <module>
class _NormalAccessor(_Accessor):
File "d:\software\python362_32\Lib\pathlib.py", line 404, in _NormalAccessor
scandir = _wrap_strfunc(os.scandir)
AttributeError: 'module' object has no attribute 'scandir'
Because scandir it’s not supported by St’s py 3.3. So yeah… summing up, I’d like to understand why in this case I’m not having a clean “sys.path”, why has it been extended in case 3) but not in case 2)?
Thanks in advance for the clarification.
@wbond PS: Talking about python3.6.2… is there any plan in the roadmap to upgrade the ST python embedded interpreter to 3.6.x or bigger? That’s a really major feature but it’d be a extremely awesome one . In fact, out of curiosity, how hard would be using a virtualenv as the embedded interpreter? Just thinking about how extensible would be ST this way gives me chills, ie: that would allow me to code (maybe?) pyqt5 plugins or using the whole python pypi ecosystem very easily in some cases where the whole threading stuff is not messed up