Problem: When trying to associate a new version of Python to a PyCharm project by creating a new virtual environment the following error message is reported, and the new python interpreter is NOT actively used:
AttributeError: module 'sysconfig' has no attribute
'_get_default_scheme'. Did you mean: 'get_default_scheme'?
I have no idea what this error relates to, or why the new version of Python is so hard to link to PyCharm (which apparently is suitable up to Python 3.11).
Background: I had set up a python project in PyCharm (Community, 2020.1.5), and started having problems with libraries, so I tried to start the project again using Python 3.10 (had previously used Python 3.6 associated with Tensorflow). I created a new virtualenv (venv4), pointing to the new Python (3.10.4 which was freshly installed from Python.org).
The new environment is created, and the python file moved... however, the python interpreter that is associated with the project is Python 3.1 (located in a different directory entirely, and apparently invalid).
Executed Commands:
C:\Users\XXXX\AppData\Local\Temp\tmppycharm-management/virtualenv.py
D:\Data\Python_Projects\XXXXXXX\venv_4
Command Output:
Using base prefix 'D:\\Applications\\Python310' New python executable
in D:\Data\Python_Projects\XXXXX\venv_4\Scripts\python.exe
C:\Users\XXXX\AppData\Local\Temp\tmppycharm-management\virtualenv.py:24:
DeprecationWarning: The distutils package is deprecated and slated for
removal in Python 3.12. Use setuptools or check PEP 632 for potential
alternatives
import distutils.spawn
C:\Users\XXXX\AppData\Local\Temp\tmppycharm-management\virtualenv.py:25:
DeprecationWarning: The distutils.sysconfig module is deprecated, use
sysconfig instead
import distutils.sysconfig
Traceback (most recent call last):
File "C:\Users\XXXX\AppData\Local\Temp\tmppycharm-management\virtualenv.py", line 2633, in <module>
main()
File "C:\Users\XXXX\AppData\Local\Temp\tmppycharm-management\virtualenv.py", line 859, in main
create_environment(
File "C:\Users\XXXX\AppData\Local\Temp\tmppycharm-management\virtualenv.py", line 1161, in create_environment
install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
File "C:\Users\XXXX\AppData\Local\Temp\tmppycharm-management\virtualenv.py", line 1720, in install_python
fix_local_scheme(home_dir, symlink)
File "C:\Users\XXXX\AppData\Local\Temp\tmppycharm-management\virtualenv.py", line 1806, in fix_local_scheme
if sysconfig._get_default_scheme() == "posix_local":
AttributeError: module 'sysconfig' has no attribute
'_get_default_scheme'. Did you mean: 'get_default_scheme'?