pypa / virtualenv

Virtual Python Environment builder
https://virtualenv.pypa.io
MIT License
4.78k stars 1.02k forks source link

Virtualenv fails to create environment on Windows #2706

Closed NtWriteCode closed 4 months ago

NtWriteCode commented 4 months ago

Issue

Simply creating a virtualenv fails.

Environment

Windows 11 x64 (23H2 22631.3447) virtualenv 20.25.3 from C:\Python311\Lib\site-packages\virtualenv__init__.py

Ps.: "Undefined" is my username, don't be fooled by it :)

Package             Version
------------------- -----------
aiohttp             3.8.5
aiohttp-retry       2.8.3
aiosignal           1.3.1
anyio               4.1.0
astunparse          1.6.3
async-timeout       4.0.2
attrs               22.2.0
bashlex             0.18
beautifulsoup4      4.12.3
blinker             1.7.0
cabfile             1.0.0
capstone            4.0.2
certifi             2022.12.7
cffi                1.15.1
chardet             3.0.4
charset-normalizer  3.2.0
click               8.1.7
clr-loader          0.2.6
cmd2                0.9.12
colorama            0.4.6
colorclass          2.2.2
cryptography        41.0.4
dhash               1.4
dnfile              0.13.0
dnspython           2.3.0
dotnetfile          0.2.4
easygui             0.98.3
exceptiongroup      1.1.3
fickling            0.1.3
filelock            3.13.4
filemagic           1.6
Flask               3.0.3
frozenlist          1.4.0
fsspec              2024.3.1
future              0.18.3
gevent              23.9.1
googlesearch-python 1.1.0
greenlet            3.0.1
h11                 0.14.0
hexdump             3.3
httpcore            1.0.2
httpx               0.25.2
idna                2.8
importlib-metadata  7.0.1
iniconfig           2.0.0
iso8601             2.1.0
itsdangerous        2.1.2
Jinja2              3.1.3
libmagic            1.0
malduck             4.3.2
MarkupSafe          2.1.5
mpmath              1.3.0
msoffcrypto-tool    5.0.0
multidict           6.0.4
networkx            3.1
numpy               1.24.3
olefile             0.46
oletools            0.60.1
opencv-python       4.7.0.72
outcome             1.3.0.post0
packaging           23.2
pcodedmp            1.2.6
pdfid               1.1.2
pefile              2022.5.30
peutils             0.0.46
Pillow              9.4.0
pip                 24.0
pluggy              1.3.0
pycparser           2.21
pycryptodome        3.18.0
pycryptodomex       3.18.0
pyelftools          0.29
pygore              0.5.0
PyJWT               2.8.0
pyOneNote           0.0.2
pyparsing           2.4.7
pypdf               3.4.0
pyperclip           1.8.2
pyreadline          2.1
pyserial            3.5
PySocks             1.7.1
pytest              7.2.2
python-magic-bin    0.4.14
python-telegram-bot 20.7
python-whois        0.8.0
pythonnet           3.0.1
pytz                2023.3
PyYAML              6.0.1
pyzipper            0.3.6
rarfile             4.0
requests            2.31.0
schedule            1.2.1
selenium            4.18.1
setuptools          56.0.0
simplejson          3.16.0
six                 1.16.0
sniffio             1.3.0
sortedcontainers    2.4.0
soupsieve           2.3.2.post1
sympy               1.12
tomli               2.0.1
torch               2.2.2
torchvision         0.17.2
trio                0.24.0
trio-websocket      0.11.1
twilio              8.5.0
types-click         7.1.8
types-Flask         1.1.6
types-Jinja2        2.11.9
types-MarkupSafe    1.1.10
types-Werkzeug      1.0.9
typing_extensions   4.9.0
unicorn-unipacker   1.0.3b7
unipacker           2.0
urllib3             2.2.1
wcwidth             0.2.5
Werkzeug            3.0.1
wheel               0.43.0
win-unicode-console 0.5
wsproto             1.2.0
xonsh               0.14.0
yara-python         4.2.3
yarl                1.9.2
zipp                3.17.0
zope.event          5.0
zope.interface      6.1

Output of the virtual environment creation

Make sure to run the creation with -vvv --with-traceback:

C:\Users\Undefined\Desktop\hardverapro-plus-plus>py -3.11 -m virtualenv demoEnv -vvv --with-traceback
106 setup logging to NOTSET [DEBUG report:36]
121 find interpreter for spec PythonSpec(path=C:\Python311\python.exe) [INFO builtin:58]
122 proposed PythonInfo(spec=CPython3.11.0.final.0-64, exe=C:\Python311\python.exe, platform=win32, version='3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]', encoding_fs_io=utf-8-utf-8) [INFO builtin:65]
122 accepted PythonInfo(spec=CPython3.11.0.final.0-64, exe=C:\Python311\python.exe, platform=win32, version='3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]', encoding_fs_io=utf-8-utf-8) [DEBUG builtin:67]
125 symlink on filesystem does not work [DEBUG info:44]
125 filesystem is not case-sensitive [DEBUG info:25]
170 create virtual environment via CPython3Windows(dest=C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv, clear=False, no_vcs_ignore=False, global=False) [INFO session:50]
171 write C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\pyvenv.cfg [DEBUG pyenv_cfg:33]
171     home = C:\Python311 [DEBUG pyenv_cfg:38]
171     implementation = CPython [DEBUG pyenv_cfg:38]
171     version_info = 3.11.0.final.0 [DEBUG pyenv_cfg:38]
171     virtualenv = 20.25.3 [DEBUG pyenv_cfg:38]
172     include-system-site-packages = false [DEBUG pyenv_cfg:38]
172     base-prefix = C:\Python311 [DEBUG pyenv_cfg:38]
173     base-exec-prefix = C:\Python311 [DEBUG pyenv_cfg:38]
173     base-executable = C:\Python311\python.exe [DEBUG pyenv_cfg:38]
173 remove file C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Scripts\python.exe [DEBUG _sync:26]
174 copy C:\Python311\Lib\venv\scripts\nt\python.exe to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Scripts\python.exe [DEBUG _sync:40]
175 remove file C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Scripts\pythonw.exe [DEBUG _sync:26]
175 copy C:\Python311\Lib\venv\scripts\nt\pythonw.exe to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Scripts\pythonw.exe [DEBUG _sync:40]
177 create virtualenv import hook file C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\_virtualenv.pth [DEBUG api:91]
177 create C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\_virtualenv.py [DEBUG api:94]
178 ============================== target debug ============================== [DEBUG session:52]
178 debug via 'C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Scripts\python.exe' 'C:\Python311\Lib\site-packages\virtualenv\create\debug.py' [DEBUG creator:200]
178 {
  "sys": {
    "executable": "C:\\Users\\Undefined\\Desktop\\hardverapro-plus-plus\\demoEnv\\Scripts\\python.exe",
    "_base_executable": "C:\\Python311\\python.exe",
    "prefix": "C:\\Users\\Undefined\\Desktop\\hardverapro-plus-plus\\demoEnv",
    "base_prefix": "C:\\Python311",
    "real_prefix": null,
    "exec_prefix": "C:\\Users\\Undefined\\Desktop\\hardverapro-plus-plus\\demoEnv",
    "base_exec_prefix": "C:\\Python311",
    "path": [
      "C:\\Python311\\python311.zip",
      "C:\\Python311\\DLLs",
      "C:\\Python311\\Lib",
      "C:\\Python311",
      "C:\\Users\\Undefined\\Desktop\\hardverapro-plus-plus\\demoEnv",
      "C:\\Users\\Undefined\\Desktop\\hardverapro-plus-plus\\demoEnv\\Lib\\site-packages"
    ],
    "meta_path": [
      "<class '_distutils_hack.DistutilsMetaFinder'>",
      "<class '_virtualenv._Finder'>",
      "<class '_frozen_importlib.BuiltinImporter'>",
      "<class '_frozen_importlib.FrozenImporter'>",
      "<class '_frozen_importlib_external.PathFinder'>"
    ],
    "fs_encoding": "utf-8",
    "io_encoding": "cp1252"
  },
  "version": "3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]",
  "makefile_filename": "C:\\Python311\\Lib\\config\\Makefile",
  "os": "<module 'os' (frozen)>",
  "site": "<module 'site' (frozen)>",
  "datetime": "<module 'datetime' from 'C:\\\\Python311\\\\Lib\\\\datetime.py'>",
  "math": "<module 'math' (built-in)>",
  "json": "<module 'json' from 'C:\\\\Python311\\\\Lib\\\\json\\\\__init__.py'>"
} [DEBUG session:53]
248 add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\Undefined\AppData\Local\pypa\virtualenv) [INFO session:57]
250 got embed update of distribution %s from ('pip', WindowsPath('C:/Users/Undefined/AppData/Local/pypa/virtualenv/wheel/3.11/embed/3/pip.json')) [DEBUG via_disk_folder:131]
250 got embed update of distribution %s from ('setuptools', WindowsPath('C:/Users/Undefined/AppData/Local/pypa/virtualenv/wheel/3.11/embed/3/setuptools.json')) [DEBUG via_disk_folder:131]
251 got embed update of distribution %s from ('wheel', WindowsPath('C:/Users/Undefined/AppData/Local/pypa/virtualenv/wheel/3.11/embed/3/wheel.json')) [DEBUG via_disk_folder:131]
254 got embed update of distribution %s from ('setuptools', WindowsPath('C:/Users/Undefined/AppData/Local/pypa/virtualenv/wheel/3.11/embed/3/setuptools.json')) [DEBUG via_disk_folder:131]
255 got embed update of distribution %s from ('pip', WindowsPath('C:/Users/Undefined/AppData/Local/pypa/virtualenv/wheel/3.11/embed/3/pip.json')) [DEBUG via_disk_folder:131]
255 got embed update of distribution %s from ('wheel', WindowsPath('C:/Users/Undefined/AppData/Local/pypa/virtualenv/wheel/3.11/embed/3/wheel.json')) [DEBUG via_disk_folder:131]
255 install setuptools from wheel C:\Python311\Lib\site-packages\virtualenv\seed\wheels\embed\setuptools-69.5.1-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
255 install pip from wheel C:\Python311\Lib\site-packages\virtualenv\seed\wheels\embed\pip-24.0-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
256 install wheel from wheel C:\Python311\Lib\site-packages\virtualenv\seed\wheels\embed\wheel-0.43.0-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
256 Attempting to acquire lock 1718517158608 on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any.lock [DEBUG _api:269]
256 Attempting to acquire lock 1718517160400 on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\pip-24.0-py3-none-any.lock [DEBUG _api:269]
256 Attempting to acquire lock 1718517162000 on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\wheel-0.43.0-py3-none-any.lock [DEBUG _api:269]
257 Lock 1718517158608 acquired on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any.lock [DEBUG _api:272]
257 Lock 1718517160400 acquired on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\pip-24.0-py3-none-any.lock [DEBUG _api:272]
257 Attempting to release lock 1718517158608 on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any.lock [DEBUG _api:302]
257 Lock 1718517162000 acquired on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\wheel-0.43.0-py3-none-any.lock [DEBUG _api:272]
257 Attempting to release lock 1718517160400 on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\pip-24.0-py3-none-any.lock [DEBUG _api:302]
257 Lock 1718517158608 released on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any.lock [DEBUG _api:305]
257 Attempting to release lock 1718517162000 on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\wheel-0.43.0-py3-none-any.lock [DEBUG _api:302]
258 Lock 1718517160400 released on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\pip-24.0-py3-none-any.lock [DEBUG _api:305]
258 Lock 1718517162000 released on C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\wheel-0.43.0-py3-none-any.lock [DEBUG _api:305]
258 uninstall existing distribution setuptools-69.5.1 from C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages [DEBUG base:154]
258 uninstall existing distribution pip-24.0 from C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages [DEBUG base:154]
258 uninstall existing distribution wheel-0.43.0 from C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages [DEBUG base:154]
294 remove directory C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\wheel [DEBUG _sync:23]
295 copy directory C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\wheel-0.43.0-py3-none-any\wheel to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\wheel [DEBUG _sync:40]
320 copy directory C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\wheel-0.43.0-py3-none-any\wheel-0.43.0.dist-info to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\wheel-0.43.0.dist-info [DEBUG _sync:40]
326 copy C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\wheel-0.43.0-py3-none-any\wheel-0.43.0.virtualenv to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\wheel-0.43.0.virtualenv [DEBUG _sync:40]
331 generated console scripts wheel3.11.exe wheel-3.11.exe wheel3.exe wheel.exe [DEBUG base:43]
336 copy C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any\distutils-precedence.pth to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\distutils-precedence.pth [DEBUG _sync:40]
337 copy directory C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any\pkg_resources to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\pkg_resources [DEBUG _sync:40]
377 copy directory C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\pip-24.0-py3-none-any\pip to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\pip [DEBUG _sync:40]
399 copy directory C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any\setuptools to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\setuptools [DEBUG _sync:40]
574 copy directory C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any\setuptools-69.5.1.dist-info to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\setuptools-69.5.1.dist-info [DEBUG _sync:40]
581 copy C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any\setuptools-69.5.1.virtualenv to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\setuptools-69.5.1.virtualenv [DEBUG _sync:40]
582 copy directory C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\setuptools-69.5.1-py3-none-any\_distutils_hack to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\_distutils_hack [DEBUG _sync:40]
585 generated console scripts  [DEBUG base:43]
783 copy directory C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\pip-24.0-py3-none-any\pip-24.0.dist-info to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\pip-24.0.dist-info [DEBUG _sync:40]
789 copy C:\Users\Undefined\AppData\Local\pypa\virtualenv\wheel\3.11\image\1\CopyPipInstall\pip-24.0-py3-none-any\pip-24.0.virtualenv to C:\Users\Undefined\Desktop\hardverapro-plus-plus\demoEnv\Lib\site-packages\pip-24.0.virtualenv [DEBUG _sync:40]
792 generated console scripts pip.exe pip3.exe pip-3.11.exe pip3.11.exe [DEBUG base:43]
793 add activators for Bash, Batch, Fish, Nushell, PowerShell, Python, Xonsh [INFO session:63]
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python311\Lib\site-packages\virtualenv\__main__.py", line 70, in <module>
    run_with_catch()  # pragma: no cov
    ^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\virtualenv\__main__.py", line 56, in run_with_catch
    run(args, options, env)
  File "C:\Python311\Lib\site-packages\virtualenv\__main__.py", line 18, in run
    session = cli_run(args, options, env)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\virtualenv\run\__init__.py", line 33, in cli_run
    of_session.run()
  File "C:\Python311\Lib\site-packages\virtualenv\run\session.py", line 46, in run
    self._activate()
  File "C:\Python311\Lib\site-packages\virtualenv\run\session.py", line 65, in _activate
    activator.generate(self.creator)
  File "C:\Python311\Lib\site-packages\virtualenv\activation\via_template.py", line 27, in generate
    generated = self._generate(replacements, self.templates(), dest_folder, creator)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\virtualenv\activation\via_template.py", line 51, in _generate
    encoding = "utf-8-sig" if template.endswith(".ps1") else "utf-8"
                              ^^^^^^^^^^^^^^^^^
AttributeError: 'WindowsPath' object has no attribute 'endswith'
NtWriteCode commented 4 months ago

Just looked around the files and it's potentially related to this commit: https://github.com/pypa/virtualenv/pull/2687/commits/4dfda232fd3edc4458a7d2a69d80706cfa2a3f37

NtWriteCode commented 4 months ago

Created related PR: https://github.com/pypa/virtualenv/pull/2707

ofek commented 4 months ago

This is fixed: https://github.com/pypa/virtualenv/pull/2707