I have Python 3.6.3 and Python 3.7 installed and when I'm trying to set up a virtual environment with 3.6.3 its throws an error and it seems Python 3.7 is being called instead despite trying to following the suggestions from SO links listed below. Windows 10 and first checking where the Python 3.6.3 executable is:
C:\>py -3.6
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
import sys
print(sys.executable) #C:\Python\python.exe
Now following the accepted answer from here:
C:\>mkdir pyvirtenv && cd pyvirtenv
C:\pyvirtenv>py -3.6 -m venv pyvirtenv
I get the following error:
File "C:\Python37\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Python37\lib\runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Python37\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "C:\Python37\lib\venv\__init__.py", line 7, in <module>
import logging
File "C:\Python37\lib\logging\__init__.py", line 26, in <module>
import sys, os, time, io, traceback, warnings, weakref, collections.abc
File "C:\Python37\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Python37\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Python37\lib\tokenize.py", line 33, in <module>
import re
File "C:\Python37\lib\re.py", line 123, in <module>
import sre_compile
File "C:\Python37\lib\sre_compile.py", line 17, in <module>
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
AssertionError: SRE module mismatch
It seems the Python 3.7 is being called even with the 3.6 command Then I tried the further alternative suggested by the accepted answer in the previous post, viz: replacing py -3.6 with the executable path but the same error persists
Also tried using virutalenv instead of venv as outlined in the Windows specific solutions here but the final error remains unchanged:
C:\pyvirtenv>virtualenv -p C:\Python\python.exe pyvirtenv
Traceback (most recent call last):
File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python\Scripts\virtualenv.exe\__main__.py", line 2, in <module>
File "C:\Python37\lib\re.py", line 123, in <module>
import sre_compile
File "C:\Python37\lib\sre_compile.py", line 17, in <module>
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
AssertionError: SRE module mismatch
Setting up virtual environment with Python 3.7 is working fine and the above problems remain even after I've removed Python 3.7 completely from the PATH and rebooted.
Thanks
edit
adding output of py -3.6 -m site
as requested in comment:
sys.path = [
'C:\\pyvirtenv',
'C:\\Python\\python36.zip',
'C:\\Python37\\DLLs',
'C:\\Python37\\lib',
'C:\\Python37',
'C:\\',
]
USER_BASE: 'C:\\Users\\shanlodh\\AppData\\Roaming\\Python' (doesn't exist)
USER_SITE: 'C:\\Users\\shanlodh\\AppData\\Roaming\\Python\\Python36\\site-packages' (doesn't exist)
ENABLE_USER_SITE: False
edit2
further update based on second round of comments below:
c: \> py -3.6 -c "import site; print(site.__file__)" #C:\Python37\lib\site.py
c:\>python37\lib\site.py
sys.path = [
'C:\\python37\\lib',
'C:\\Python37\\python37.zip',
'C:\\Python37\\DLLs',
'C:\\Python37',
'C:\\',
]
USER_BASE: 'C:\\Users\\shanlodh\\AppData\\Roaming\\Python' (doesn't exist)
USER_SITE: 'C:\\Users\\shanlodh\\AppData\\Roaming\\Python\\Python37\\site-packages' (doesn't exist)
ENABLE_USER_SITE: False