Open Anti-Distinctlyminty opened 3 years ago
A PR fixing this would be appreciated.
Hello - Is this error specific to OP's environment and his packages installed in the environment? I tried creating a new virtualenv and didn't see the issue. Both cmd's activate and powershell's activate show the correct virtualenv name.
Odd. I am no longer seeing it. I shall reopen if I can reproduce.
I've ended up back here again. Again it does seem to be something to do with UNC paths. I've created a virual environment on a network drive. To reproduce:
In powershell navigate to some network location using a mapped drive and create the virtual env:
PS > cd T:\__Tests\temp
PS T:\__Tests\temp > C:\Python27\python.exe -m virtualenv .venv -vvv
Activate it. As shown here you may have to set the execution policy
PS T:\__Tests\temp > set-executionpolicy unrestricted -scope process
PS T:\__Tests\temp > .venv\Scritps\activate
Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your computer. If you trust this
script, use the Unblock-File cmdlet to allow the script to run without this warning message. Do you want to run
T:\__Tests\temp\.venv\Scripts\activate.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): r
(.venv) PS T:\__Tests\temp > py
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Ok, all good. Now let's use exactly the same .venv on a UNC path...
PS Microsoft.PowerShell.Core\FileSystem::\\x.x.x.x\__Tests\temp> .\.venv\Scripts\activate
Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your computer. If you trust this
script, use the Unblock-File cmdlet to allow the script to run without this warning message. Do you want to run
\\192.168.15.130\projects\__Tests\temp\.venv\Scripts\activate.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): r
(activate.ps1) PS Microsoft.PowerShell.Core\FileSystem::\\x.x.x.x\__Tests\temp> py
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Not only is the virtualenv name incorrect, but the activation isn't actually working, it just picks up whatever python is first on path. Checking the path environment shows why, as the injected path is clearly incorrect.
(activate.ps1) PS Microsoft.PowerShell.Core\FileSystem::\\x.x.x.x\__Tests\temp> echo $env:PATH
Microsoft.PowerShell.Core\FileSystem::\\x.x.x.x\__Tests\temp\.venv\Scripts\activate.ps1/Scripts;...
virtualenv version 20.14.0
Issue
When using the
Activate.ps1
script, the name in parenthesis becomes(activate.ps1)
, as opposed to the name of the virtual environment when using the bat file.Environment
Provide at least:
pip list
of the host python wherevirtualenv
is installed:Output
```console Package Version ------------------ -------------- -ip 20.1.1 -irtualenv 20.4.3 <-- This looks suspicious appdirs 1.4.4 atomicwrites 1.3.0 attrs 19.3.0 autopep8 1.5 cairocffi 1.2.0 CairoSVG 2.5.2 certifi 2020.12.5 cffi 1.14.5 chardet 4.0.0 colorama 0.4.1 cssselect2 0.4.1 defusedxml 0.7.1 distlib 0.3.1 expandvars 0.6.5 filelock 3.0.12 future-fstrings 1.2.0 html5lib 1.1 idna 2.10 importlib-metadata 3.10.0 jsonschema 2.6.0 logging-tree 1.8 logx 0.1.1562053912 mistune 0.8.4 more-itertools 8.0.0 mutagen 1.45.1 packaging 19.2 peewee 3.13.3 pgpubsub 0.0.5 Pillow 8.1.2 pip 21.0.1 pluggy 0.13.1 psycopg2-binary 2.8.4 ptvsd 4.3.2 py 1.8.0 pycodestyle 2.5.0 pycparser 2.20 pyparsing 2.4.5 Pyphen 0.10.0 pyseq 0.5.1 pytest 5.3.1 PyYAML 5.2 requests 2.25.1 sentry-sdk 0.19.4 setuptools 47.1.0 setuptools-scm 3.5.0 simplejson 3.17.0 six 1.15.0 spotipy 2.16.1 tinycss2 1.1.0 typing-extensions 3.7.4.3 urllib3 1.26.4 virtualenv 20.4.3 wcwidth 0.1.7 WeasyPrint 52.4 webencodings 0.5.1 youtube-dl 2021.3.25 zipp 3.4.1 ```Output of the virtual environment creation
Make sure to run the creation with
-vvv --with-traceback
:TheREDACTED_PATH
listed below in Output is a UNC path. Maybe this is the cause?Output
```console 183 setup logging to NOTSET [DEBUG report:43] 280 find interpreter for spec PythonSpec(path=c:\python37\python.exe) [INFO builtin:62] 280 proposed PythonInfo(spec=CPython3.7.3.final.0-64, exe=c:\python37\python.exe, platform=win32, version='3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]', encoding_fs_io=utf-8-utf-8) [INFO builtin:69] 280 accepted PythonInfo(spec=CPython3.7.3.final.0-64, exe=c:\python37\python.exe, platform=win32, version='3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]', encoding_fs_io=utf-8-utf-8) [DEBUG builtin:71] 292 symlink on filesystem does not work [DEBUG info:47] 293 filesystem is not case-sensitive [DEBUG info:28] 474 create virtual environment via CPython3Windows(dest=\\REDACTED_PATH\.test, clear=False, no_vcs_ignore=False, global=False) [INFO session:52] 490 create folder \\REDACTED_PATH\.test\Lib\site-packages [DEBUG _sync:25] 576 create folder \\REDACTED_PATH\.test\Scripts [DEBUG _sync:25] 617 write \\REDACTED_PATH\.test\pyvenv.cfg [DEBUG pyenv_cfg:34] 618 home = c:\python37 [DEBUG pyenv_cfg:38] 618 implementation = CPython [DEBUG pyenv_cfg:38] 619 version_info = 3.7.3.final.0 [DEBUG pyenv_cfg:38] 619 virtualenv = 20.4.3 [DEBUG pyenv_cfg:38] 620 include-system-site-packages = false [DEBUG pyenv_cfg:38] 620 base-prefix = c:\python37 [DEBUG pyenv_cfg:38] 620 base-exec-prefix = c:\python37 [DEBUG pyenv_cfg:38] 621 base-executable = c:\python37\python.exe [DEBUG pyenv_cfg:38] 681 copy c:\python37\Lib\venv\scripts\nt\python.exe to \\REDACTED_PATH\.test\Scripts\python.exe [DEBUG _sync:52] 1098 copy c:\python37\Lib\venv\scripts\nt\pythonw.exe to \\REDACTED_PATH\.test\Scripts\pythonw.exe [DEBUG _sync:52] 1513 create virtualenv import hook file \\REDACTED_PATH\.test\Lib\site-packages\_virtualenv.pth [DEBUG api:95] 1554 create \\REDACTED_PATH\.test\Lib\site-packages\_virtualenv.py [DEBUG api:98] 1644 ============================== target debug ============================== [DEBUG session:54] 1645 debug via '\\REDACTED_PATH\.test\Scripts\python.exe' 'c:\python37\lib\site-packages\virtualenv\create\debug.py' [DEBUG creator:224] 1644 { "sys": { "executable": "\\\\192.168.15.130\\projects\\__Tests\\Python\\expandvars\\.test\\Scripts\\python.exe", "_base_executable": "c:\\python37\\python.exe", "prefix": "\\\\192.168.15.130\\projects\\__Tests\\Python\\expandvars\\.test", "base_prefix": "c:\\python37", "real_prefix": null, "exec_prefix": "\\\\192.168.15.130\\projects\\__Tests\\Python\\expandvars\\.test", "base_exec_prefix": "c:\\python37", "path": [ "c:\\python37\\python37.zip", "c:\\python37\\DLLs", "c:\\python37\\lib", "c:\\python37", "\\\\192.168.15.130\\projects\\__Tests\\Python\\expandvars\\.test", "\\\\192.168.15.130\\projects\\__Tests\\Python\\expandvars\\.test\\lib\\site-packages" ], "meta_path": [ "