Intellij IDEA Ultimate: unable to create virtual environment

Answered

Hi -

I'm trying to create a virtual environment for various Python projects, using IDEA's graphical UIs, and I'm getting the following error message:
"Failed to Created Interpreter"
'Failed to create a virtual environment'

and the following in the IntelliJ log:

2022-05-16 10:44:56,949 [ 122693]   INFO - #c.j.p.p.PyPackageManagerImpl - Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/__main__.py", line 167, in <module>
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/__main__.py", line 163, in run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/__main__.py", line 18, in run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/run/__init__.py", line 32, in cli_run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/run/session.py", line 46, in run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/run/session.py", line 53, in _create
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/creator.py", line 171, in run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/builtin/via_global_self_do.py", line 101, in create
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/api.py", line 89, in create
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/api.py", line 92, in install_patch
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py", line 27, in env_patch_text
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/api.py", line 103, in env_patch_text
  File "/usr/local/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/app_data/base.py", line 58, in ensure_extracted
  File "/usr/local/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/app_data/via_disk_folder.py", line 83, in extract
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/util/zipapp.py", line 22, in extract
    
  File "/usr/local/lib/python3.8/zipfile.py", line 1441, in getinfo
    raise KeyError(
KeyError: "There is no item named 'ualenv/create/via_global_ref/_virtualenv.py' in the archive"


Is this a simple configuration problem, or is this a bug? I'm currently working around this with the command line, but thought I would ask if this was a known issue. I didn't find anything immediately in YouTrack.

Thanks for your help!
Best,

Bridger

0
7 comments

Could you try creating a virtualenv using another interpreter as a base?

Does the same error appear?

1

Hi Sergey Karpov -
Thanks for your suggestion (and apologies for the slow response).

I've added Python v3.9 and have tried creating the virtualenv with it as the base, but get the same error:

 

2022-05-19 11:38:37,712 [ 982087]   INFO - #c.j.p.p.PyPackageManagerImpl - Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/__main__.py", line 167, in <module>
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/__main__.py", line 163, in run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/__main__.py", line 18, in run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/run/__init__.py", line 32, in cli_run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/run/session.py", line 46, in run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/run/session.py", line 53, in _create
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/creator.py", line 171, in run
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/builtin/via_global_self_do.py", line 101, in create
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/api.py", line 89, in create
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/api.py", line 92, in install_patch
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py", line 27, in env_patch_text
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/create/via_global_ref/api.py", line 103, in env_patch_text
  File "/usr/local/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/app_data/base.py", line 58, in ensure_extracted
  File "/usr/local/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/app_data/via_disk_folder.py", line 83, in extract
  File "/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz/virtualenv/util/zipapp.py", line 22, in extract
    
  File "/usr/local/lib/python3.9/zipfile.py", line 1438, in getinfo
    raise KeyError(
KeyError: "There is no item named 'ualenv/create/via_global_ref/_virtualenv.py' in the archive"

 

Any other suggestions? Should I create a YouTrack ticket for this?

0

Does running python3 -S /path/to/virtualenv.pyz /destination/folder also fail in the command line?

If so, check if it works with the same virtualenv version (PyCharm currently uses 20.13.0) installed from PyPI.

0

Hi Sergey Karpov - thanks for the continued help.

I've tried your suggestion with both python3.8 (my default `python3`) and python3.9, and both commands are successful; e.g.

± python3 -S /usr/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz venv
created virtual environment CPython3.8.13.final.0-64 in 828ms
  creator CPython3Posix(dest=/usr/home/bridger/src/trace_work_types_planning/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/usr/home/bridger/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==60.2.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

and

± python3.9 -S /usr/home/bridger/.local/share/JetBrains/IntelliJIdea2022.1/python/helpers/virtualenv.pyz venv
created virtual environment CPython3.9.12.final.0-64 in 751ms
  creator CPython3Posix(dest=/usr/home/bridger/src/trace_work_types_planning/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/usr/home/bridger/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==60.2.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

 

0

Hmm, interesting.
Could you indeed file a bug to https://youtrack.jetbrains.com/issues/PY and attach your idea.log file from Help | Show Log in...?
It will be easier to continue the investigation there as the forum doesn't allow file attachments.

0

Sergey Karpov - apologies for the slow response. Between the creation of this thread and Monday, I applied a system update and now this doesn't seem to be a problem any more. I'm not exactly sure what changed, but this seems to be resolved. Thank you again for the help trying to triage the problem!

0

It is a bug in virtualenv when i install jetbraintoolbox with scoop. The full_path is not the realpath of it but a link. So i add that in red box and now work normally.

3

Please sign in to leave a comment.