Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken environment built via virtualenv venv with scheme posix_local in Debian testing bookworm #2350

Closed
yingmanwumen opened this issue Jun 5, 2022 · 11 comments · Fixed by #2415
Labels

Comments

@yingmanwumen
Copy link

yingmanwumen commented Jun 5, 2022

Issue

Debian has set the sysconfig default scheme from posix_prefix to posix_local(https://lists.debian.org/debian-python/2022/03/msg00039.html). And when posix_local being chosen, the default ./venv/bin/activate is set to ./venv/local/bin/activate -- AND, it is BROKEN.

Reproduce:

Open an empty directory and use the command virtualenv venv

$ virtualenv venv
created virtual environment CPython3.10.4.final.0-64 in 101ms
  creator CPython3Posix(dest=/home/yingmanwumen/Desktop/test/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/yingmanwumen/.local/share/virtualenv)
    added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

the sysconfig scheme is posix_local:

$ python -m sysconfig
Platform: "linux-x86_64"
Python version: "3.10"
Current installation scheme: "posix_local"

Paths:
	data = "/usr/local"
	include = "/usr/include/python3.10"
	platinclude = "/usr/include/python3.10"
	platlib = "/usr/local/lib/python3.10/dist-packages"
	platstdlib = "/usr/lib/python3.10"
	purelib = "/usr/local/lib/python3.10/dist-packages"
	scripts = "/usr/local/bin"
	stdlib = "/usr/lib/python3.10"
...

And the directories:

$ tree -L 3
.
└── venv
    ├── lib
    │   └── python3.10
    ├── local
    │   ├── bin
    │   └── lib
    └── pyvenv.cfg

6 directories, 1 file

Activate the venv by source ./venv/local/bin/activate, then use the command pip list:

pip list
Package             Version
------------------- --------------
appdirs             1.4.4
asciinema           2.2.0
attrs               21.2.0
beautifulsoup4      4.11.1
Brlapi              0.8.3
Brotli              1.0.9
bs4                 0.0.1
certifi             2020.6.20
chardet             4.0.0
charset-normalizer  2.0.6
click               8.1.3
colorama            0.4.4
commonmark          0.9.1
cppman              0.5.3
cupshelpers         1.0
cycler              0.11.0
dbus-python         1.2.18
decorator           4.4.2
distlib             0.3.4
distro              1.7.0
distro-info         1.1
dlib                19.23.1
filelock            3.6.0
Flask               2.1.2
fonttools           4.32.0
fs                  2.4.12
fuse-python         1.0.5
gpg                 1.16.0-unknown
greenlet            1.1.2
gyp                 0.1
html5lib            1.1
idna                3.3
importlib-metadata  4.6.4
iniconfig           1.1.1
itsdangerous        2.1.2
Jinja2              3.1.2
jsonschema          3.2.0
kaggle              1.5.12
kiwisolver          1.3.2
louis               3.21.0
lxml                4.8.0
lz4                 4.0.0+dfsg
Mako                1.1.3
Markdown            3.3.7
MarkupSafe          2.1.1
matplotlib          3.5.1
memray              1.0.3
mercurial           6.1.2
more-itertools      8.10.0
mpmath              0.0.0
msgpack             1.0.3
mutagen             1.45.1
numpy               1.21.5
olefile             0.46
opencv-python       4.5.5.64
packaging           21.3
pbr                 5.9.0
perf                0.1
pexpect             4.8.0
Pillow              9.0.1
pip                 22.1.1
pip-review          1.1.1
pip-search          0.0.12
platformdirs        2.5.2
pluggy              1.0.0
psutil              5.9.0
ptyprocess          0.7.0
py                  1.11.0
PyAudio             0.2.11
pycairo             1.20.1
pycryptodomex       3.11.0
pycups              2.0.1
pycurl              7.44.1
Pygments            2.11.2
PyGObject           3.42.1
pylibacl            0.6.0
pynvim              0.4.2
pyparsing           3.0.7
PyQt5               5.15.6
PyQt5-sip           12.10.1
PyQtWebEngine       5.15.5
pyrsistent          0.18.1
pysmbc              1.0.23
pyte                0.8.0
pytest              7.1.2
pytest-memray       1.0.0
python-apt          2.3.0+b1
python-dateutil     2.8.1
python-debian       0.1.44
python-slugify      6.1.2
pytz                2022.1
pyxattr             0.7.2
pyxdg               0.27
PyYAML              5.4.1
requests            2.27.1
rich                10.16.2
scipy               1.8.1
screenkey           1.5
Send2Trash          1.8.1b0
setuptools          62.3.2
six                 1.16.0
soupsieve           2.3.2.post1
specan              0.0.0
stevedore           3.5.0
sympy               1.10.1
text-unidecode      1.3
tomli               2.0.1
tornado             6.1
tqdm                4.64.0
trash-cli           0.22.4.16
ufoLib2             0.13.1
unattended-upgrades 0.1
unicodedata2        14.0.0
urllib3             1.26.9
virtualenv          20.14.1
virtualenv-clone    0.5.7
virtualenvwrapper   4.8.4
wcwidth             0.2.5
webencodings        0.5.1
websockets          10.3
Werkzeug            2.1.2
wheel               0.37.1
xdg                 5.1.1
xxh-xxh             0.8.10
yt-dlp              2022.5.18
zipp                3.8.0

It is the result of the host pip list!!

I have found the same issue #2340.

It is easy to solve this by add export DEB_PYTHON_INSTALL_LAYOUT='deb' to ~/.bashrc to change sysconfig scheme from posix_local to deb_system, but I think a proper solution is needed ^_^

Environment

Provide at least:

  • OS: Debian testing bookworm
  • pip list of the host python where virtualenv is installed:
Package             Version
------------------- --------------
appdirs             1.4.4
asciinema           2.2.0
attrs               21.2.0
beautifulsoup4      4.11.1
Brlapi              0.8.3
Brotli              1.0.9
bs4                 0.0.1
certifi             2020.6.20
chardet             4.0.0
charset-normalizer  2.0.6
click               8.1.3
colorama            0.4.4
commonmark          0.9.1
cppman              0.5.3
cupshelpers         1.0
cycler              0.11.0
dbus-python         1.2.18
decorator           4.4.2
distlib             0.3.4
distro              1.7.0
distro-info         1.1
dlib                19.23.1
filelock            3.6.0
Flask               2.1.2
fonttools           4.32.0
fs                  2.4.12
fuse-python         1.0.5
gpg                 1.16.0-unknown
greenlet            1.1.2
gyp                 0.1
html5lib            1.1
idna                3.3
importlib-metadata  4.6.4
iniconfig           1.1.1
itsdangerous        2.1.2
Jinja2              3.1.2
jsonschema          3.2.0
kaggle              1.5.12
kiwisolver          1.3.2
louis               3.21.0
lxml                4.8.0
lz4                 4.0.0+dfsg
Mako                1.1.3
Markdown            3.3.7
MarkupSafe          2.1.1
matplotlib          3.5.1
memray              1.0.3
mercurial           6.1.2
more-itertools      8.10.0
mpmath              0.0.0
msgpack             1.0.3
mutagen             1.45.1
numpy               1.21.5
olefile             0.46
opencv-python       4.5.5.64
packaging           21.3
pbr                 5.9.0
perf                0.1
pexpect             4.8.0
Pillow              9.0.1
pip                 22.1.1
pip-review          1.1.1
pip-search          0.0.12
platformdirs        2.5.2
pluggy              1.0.0
psutil              5.9.0
ptyprocess          0.7.0
py                  1.11.0
PyAudio             0.2.11
pycairo             1.20.1
pycryptodomex       3.11.0
pycups              2.0.1
pycurl              7.44.1
Pygments            2.11.2
PyGObject           3.42.1
pylibacl            0.6.0
pynvim              0.4.2
pyparsing           3.0.7
PyQt5               5.15.6
PyQt5-sip           12.10.1
PyQtWebEngine       5.15.5
pyrsistent          0.18.1
pysmbc              1.0.23
pyte                0.8.0
pytest              7.1.2
pytest-memray       1.0.0
python-apt          2.3.0+b1
python-dateutil     2.8.1
python-debian       0.1.44
python-slugify      6.1.2
pytz                2022.1
pyxattr             0.7.2
pyxdg               0.27
PyYAML              5.4.1
requests            2.27.1
rich                10.16.2
scipy               1.8.1
screenkey           1.5
Send2Trash          1.8.1b0
setuptools          62.3.2
six                 1.16.0
soupsieve           2.3.2.post1
specan              0.0.0
stevedore           3.5.0
sympy               1.10.1
text-unidecode      1.3
tomli               2.0.1
tornado             6.1
tqdm                4.64.0
trash-cli           0.22.4.16
ufoLib2             0.13.1
unattended-upgrades 0.1
unicodedata2        14.0.0
urllib3             1.26.9
virtualenv          20.14.1
virtualenv-clone    0.5.7
virtualenvwrapper   4.8.4
wcwidth             0.2.5
webencodings        0.5.1
websockets          10.3
Werkzeug            2.1.2
wheel               0.37.1
xdg                 5.1.1
xxh-xxh             0.8.10
yt-dlp              2022.5.18
zipp                3.8.0

Output of the virtual environment creation

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

390 setup logging to NOTSET [DEBUG report:39]
397 find interpreter for spec PythonSpec(path=/usr/bin/python) [INFO builtin:62]
397 proposed PythonInfo(spec=CPython3.10.4.final.0-64, exe=/usr/bin/python, platform=linux, version='3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0]', encoding_fs_io=utf-8-utf-8) [INFO builtin:69]
397 accepted PythonInfo(spec=CPython3.10.4.final.0-64, exe=/usr/bin/python, platform=linux, version='3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0]', encoding_fs_io=utf-8-utf-8) [DEBUG builtin:71]
400 filesystem is case-sensitive [DEBUG info:29]
426 create virtual environment via CPython3Posix(dest=/home/yingmanwumen/Desktop/test/venv, clear=False, no_vcs_ignore=False, global=False) [INFO session:52]
426 create folder /home/yingmanwumen/Desktop/test/venv/lib/python3.10 [DEBUG _sync:24]
426 create folder /home/yingmanwumen/Desktop/test/venv/local/bin [DEBUG _sync:24]
427 create folder /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages [DEBUG _sync:24]
427 write /home/yingmanwumen/Desktop/test/venv/pyvenv.cfg [DEBUG pyenv_cfg:34]
428 	home = /usr [DEBUG pyenv_cfg:38]
428 	implementation = CPython [DEBUG pyenv_cfg:38]
428 	version_info = 3.10.4.final.0 [DEBUG pyenv_cfg:38]
428 	virtualenv = 20.14.1 [DEBUG pyenv_cfg:38]
428 	include-system-site-packages = false [DEBUG pyenv_cfg:38]
428 	base-prefix = /usr [DEBUG pyenv_cfg:38]
428 	base-exec-prefix = /usr [DEBUG pyenv_cfg:38]
428 	base-executable = /usr/bin/python [DEBUG pyenv_cfg:38]
428 symlink /usr/bin/python to /home/yingmanwumen/Desktop/test/venv/local/bin/python [DEBUG _sync:43]
428 create virtualenv import hook file /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/_virtualenv.pth [DEBUG api:95]
428 create /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/_virtualenv.py [DEBUG api:98]
429 ============================== target debug ============================== [DEBUG session:54]
429 debug via /home/yingmanwumen/Desktop/test/venv/local/bin/python /home/yingmanwumen/.local/lib/python3.10/site-packages/virtualenv/create/debug.py [DEBUG creator:224]
429 {
  "sys": {
    "executable": "/home/yingmanwumen/Desktop/test/venv/local/bin/python",
    "_base_executable": "/home/yingmanwumen/Desktop/test/venv/local/bin/python",
    "prefix": "/usr",
    "base_prefix": "/usr",
    "real_prefix": null,
    "exec_prefix": "/usr",
    "base_exec_prefix": "/usr",
    "path": [
      "/usr/lib/python310.zip",
      "/usr/lib/python3.10",
      "/usr/lib/python3.10/lib-dynload",
      "/home/yingmanwumen/.local/lib/python3.10/site-packages",
      "/usr/local/lib/python3.10/dist-packages",
      "/usr/lib/python3/dist-packages",
      "/usr/lib/python3.10/dist-packages"
    ],
    "meta_path": [
      "<class '_distutils_hack.DistutilsMetaFinder'>",
      "<class '_frozen_importlib.BuiltinImporter'>",
      "<class '_frozen_importlib.FrozenImporter'>",
      "<class '_frozen_importlib_external.PathFinder'>"
    ],
    "fs_encoding": "utf-8",
    "io_encoding": "utf-8"
  },
  "version": "3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0]",
  "makefile_filename": "/usr/lib/python3.10/config-3.10-x86_64-linux-gnu/Makefile",
  "os": "<module 'os' from '/usr/lib/python3.10/os.py'>",
  "site": "<module 'site' from '/usr/lib/python3.10/site.py'>",
  "datetime": "<module 'datetime' from '/usr/lib/python3.10/datetime.py'>",
  "math": "<module 'math' (built-in)>",
  "json": "<module 'json' from '/usr/lib/python3.10/json/__init__.py'>"
} [DEBUG session:55]
468 add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/yingmanwumen/.local/share/virtualenv) [INFO session:59]
470 got embed update of distribution wheel from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/wheel.json [DEBUG via_disk_folder:135]
470 got embed update of distribution setuptools from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/setuptools.json [DEBUG via_disk_folder:135]
470 got embed update of distribution pip from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/pip.json [DEBUG via_disk_folder:135]
473 got embed update of distribution pip from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/pip.json [DEBUG via_disk_folder:135]
473 got embed update of distribution setuptools from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/setuptools.json [DEBUG via_disk_folder:135]
474 got embed update of distribution wheel from /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/embed/3/wheel.json [DEBUG via_disk_folder:135]
474 install pip from wheel /home/yingmanwumen/.local/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-22.0.4-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
474 install setuptools from wheel /home/yingmanwumen/.local/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/setuptools-62.1.0-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
474 install wheel from wheel /home/yingmanwumen/.local/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/wheel-0.37.1-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
475 Attempting to acquire lock 139837408603792 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any.lock [DEBUG _api:169]
475 Attempting to acquire lock 139837408607248 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any.lock [DEBUG _api:169]
475 Attempting to acquire lock 139837408607104 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any.lock [DEBUG _api:169]
475 Lock 139837408603792 acquired on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any.lock [DEBUG _api:173]
475 Lock 139837408607248 acquired on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any.lock [DEBUG _api:173]
475 Lock 139837408607104 acquired on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any.lock [DEBUG _api:173]
475 Attempting to release lock 139837408603792 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any.lock [DEBUG _api:203]
475 Attempting to release lock 139837408607248 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any.lock [DEBUG _api:203]
475 Lock 139837408603792 released on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any.lock [DEBUG _api:206]
475 Attempting to release lock 139837408607104 on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any.lock [DEBUG _api:203]
475 Lock 139837408607248 released on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any.lock [DEBUG _api:206]
476 Lock 139837408607104 released on /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any.lock [DEBUG _api:206]
476 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any/pip to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/pip [DEBUG _sync:51]
476 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/setuptools-62.1.0.dist-info to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/setuptools-62.1.0.dist-info [DEBUG _sync:51]
476 copy /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any/wheel-0.37.1.virtualenv to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/wheel-0.37.1.virtualenv [DEBUG _sync:51]
477 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any/wheel-0.37.1.dist-info to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/wheel-0.37.1.dist-info [DEBUG _sync:51]
478 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/setuptools to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/setuptools [DEBUG _sync:51]
479 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/wheel-0.37.1-py2.py3-none-any/wheel to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/wheel [DEBUG _sync:51]
486 generated console scripts wheel wheel3.10 wheel-3.10 wheel3 [DEBUG base:45]
528 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/_distutils_hack to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/_distutils_hack [DEBUG _sync:51]
529 copy /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/distutils-precedence.pth to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/distutils-precedence.pth [DEBUG _sync:51]
529 copy /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/setuptools-62.1.0.virtualenv to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/setuptools-62.1.0.virtualenv [DEBUG _sync:51]
529 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/setuptools-62.1.0-py3-none-any/pkg_resources to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/pkg_resources [DEBUG _sync:51]
540 generated console scripts  [DEBUG base:45]
580 copy /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any/pip-22.0.4.virtualenv to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/pip-22.0.4.virtualenv [DEBUG _sync:51]
580 copy directory /home/yingmanwumen/.local/share/virtualenv/wheel/3.10/image/1/CopyPipInstall/pip-22.0.4-py3-none-any/pip-22.0.4.dist-info to /home/yingmanwumen/Desktop/test/venv/local/lib/python3.10/dist-packages/pip-22.0.4.dist-info [DEBUG _sync:51]
586 generated console scripts pip pip3 pip-3.10 pip3.10 [DEBUG base:45]
586 add activators for Bash, CShell, Fish, Nushell, PowerShell, Python [INFO session:64]
588 write /home/yingmanwumen/Desktop/test/venv/pyvenv.cfg [DEBUG pyenv_cfg:34]
588 	home = /usr [DEBUG pyenv_cfg:38]
588 	implementation = CPython [DEBUG pyenv_cfg:38]
588 	version_info = 3.10.4.final.0 [DEBUG pyenv_cfg:38]
588 	virtualenv = 20.14.1 [DEBUG pyenv_cfg:38]
588 	include-system-site-packages = false [DEBUG pyenv_cfg:38]
588 	base-prefix = /usr [DEBUG pyenv_cfg:38]
588 	base-exec-prefix = /usr [DEBUG pyenv_cfg:38]
588 	base-executable = /usr/bin/python [DEBUG pyenv_cfg:38]
588 created virtual environment CPython3.10.4.final.0-64 in 200ms
  creator CPython3Posix(dest=/home/yingmanwumen/Desktop/test/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/yingmanwumen/.local/share/virtualenv)
    added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator [WARNING __main__:19]
@gaborbernat
Copy link
Contributor

PR addressing this is welcome.

@icezyclon
Copy link

I have found the same issue #2340.

It is easy to solve this by add export DEB_PYTHON_INSTALL_LAYOUT='deb' to ~/.bashrc to change sysconfig scheme from posix_local to deb_system, but I think a proper solution is needed ^_^

Thank you so much for the solution! Sure it isn't a "proper" solution but it restores the behavior that I wanted and couldn't get to work! 🙈
@yingmanwumen is it alright for you if I post this solution in AskUbuntu?

@toto6038
Copy link

I encounter the same problem with Python 3.10.4 on Ubuntu 22.04. It will result in poetry keeping recreating virtual environment on existing environment and prompting "The virtual environment found in [virtual environment path] seems to be broken". Moreover, when using poetry shell the virtual environment cannot be activated because poetry searches for /venv/bin/activate rather than /venv/local/bin/activate.

@frenzymadness
Copy link
Contributor

It seems that we have the same issue in Fedora. Strange is that even we have the same installation scheme for Python 3.10 (default) and 3.11 (beta) the result is different:

$ python3.11 -m sysconfig | head -n 15
Platform: "linux-x86_64"
Python version: "3.11"
Current installation scheme: "posix_prefix"

Paths: 
	data = "/usr/local"
	include = "/usr/include/python3.11"
	platinclude = "/usr/include/python3.11"
	platlib = "/usr/local/lib64/python3.11/site-packages"
	platstdlib = "/usr/lib64/python3.11"
	purelib = "/usr/local/lib/python3.11/site-packages"
	scripts = "/usr/local/bin"
	stdlib = "/usr/lib64/python3.11"

$ python3.10 -m sysconfig | head -n 15
Platform: "linux-x86_64"
Python version: "3.10"
Current installation scheme: "posix_prefix"

Paths: 
	data = "/usr/local"
	include = "/usr/include/python3.10"
	platinclude = "/usr/include/python3.10"
	platlib = "/usr/local/lib64/python3.10/site-packages"
	platstdlib = "/usr/lib64/python3.10"
	purelib = "/usr/local/lib/python3.10/site-packages"
	scripts = "/usr/local/bin"
	stdlib = "/usr/lib64/python3.10"

$ virtualenv --python /usr/bin/python3.11 test11
created virtual environment CPython3.11.0.beta.4-64 in 394ms
  creator CPython3Posix(dest=/tmp/test11, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(extra_search_dir=/usr/share/python-wheels,download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/lbalhar/.local/share/virtualenv)
    added seed packages: pip==22.1.2, setuptools==62.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

$ virtualenv --python /usr/bin/python3.10 test10
created virtual environment CPython3.10.5.final.0-64 in 320ms
  creator CPython3Posix(dest=/tmp/test10, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(extra_search_dir=/usr/share/python-wheels,download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/lbalhar/.local/share/virtualenv)
    added seed packages: pip==22.1.2, setuptools==62.3.2, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

$ tree -L 2 test11
test11
├── lib64
│   └── python3.11
├── local
│   ├── bin
│   ├── lib
│   └── lib64
└── pyvenv.cfg

$ tree -L 2 test10
test10
├── bin
│   ├── activate
│   ├── activate.csh
│   ├── activate.fish
│   ├── activate.nu
│   ├── activate.ps1
│   ├── activate_this.py
│   ├── deactivate.nu
│   ├── pip
│   ├── pip3
│   ├── pip-3.10
│   ├── pip3.10
│   ├── python -> /usr/bin/python3.10
│   ├── python3 -> python
│   ├── python3.10 -> python
│   ├── wheel
│   ├── wheel3
│   ├── wheel-3.10
│   └── wheel3.10
├── lib
│   └── python3.10
├── lib64
│   └── python3.10
└── pyvenv.cfg

@frenzymadness
Copy link
Contributor

I don't know what I did but I'm no longer able to reproduce the issue. It works fine for me with Python 3.11 beta 4 and 5.

@hroncok
Copy link
Contributor

hroncok commented Aug 2, 2022

I think Debian needs to adapt this change: deadsnakes/python3.10@9b93d73 -- what is the best channel to let them know?

More specifically:

_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_prefix']

@hroncok
Copy link
Contributor

hroncok commented Aug 2, 2022

I'm just going to cc @stefanor here and hope they will see it (the previous comment).

@hroncok
Copy link
Contributor

hroncok commented Aug 2, 2022

More context in #2208

@rpatterson
Copy link

Just ran into this as well and I have a few observations to add in case they're helpful. Firstly, I found #1663 which describes a different broken layout but a broken layout nonetheless and so maybe related? Secondly, the venv module works, including when used via the $ vritualenv --creator=... option:

rpatterson@rpatterson:~$ /usr/bin/python3 -m venv /tmp/venv1
rpatterson@rpatterson:~$ ls -al /tmp/venv1total 372
drwxrwxr-x  5 rpatterson rpatterson   4096 Aug 31 14:23 .
drwxrwxrwt 33 root       root       356352 Aug 31 14:23 ..
drwxrwxr-x  2 rpatterson rpatterson   4096 Aug 31 14:23 bin
drwxrwxr-x  2 rpatterson rpatterson   4096 Aug 31 14:23 include
drwxrwxr-x  3 rpatterson rpatterson   4096 Aug 31 14:23 lib
lrwxrwxrwx  1 rpatterson rpatterson      3 Aug 31 14:23 lib64 -> lib
-rw-rw-r--  1 rpatterson rpatterson     70 Aug 31 14:23 pyvenv.cfg
rpatterson@rpatterson:~$ /usr/bin/python3 -m virtualenv --creator venv /tmp/venv2                                                                                                                               
created virtual environment CPython3.10.4.final.0-64 in 94ms
  creator Venv(dest=/tmp/venv2, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Posix)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/rpatterson/.local/share/virtualenv)
    added seed packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
rpatterson@rpatterson:~$ ls -al /tmp/venv2
total 380
drwxrwxr-x  6 rpatterson rpatterson   4096 Aug 31 14:23 .
drwxrwxrwt 34 root       root       356352 Aug 31 14:23 ..
drwxrwxr-x  2 rpatterson rpatterson   4096 Aug 31 14:23 bin
-rw-rw-r--  1 rpatterson rpatterson     40 Aug 31 14:23 .gitignore
drwxrwxr-x  2 rpatterson rpatterson   4096 Aug 31 14:23 include
drwxrwxr-x  3 rpatterson rpatterson   4096 Aug 31 14:23 lib
lrwxrwxrwx  1 rpatterson rpatterson      3 Aug 31 14:23 lib64 -> lib
drwxrwxr-x  4 rpatterson rpatterson   4096 Aug 31 14:23 local
-rw-rw-r--  1 rpatterson rpatterson    146 Aug 31 14:23 pyvenv.cfg

Finally for those running into this with tox, you may find tox-venv helpful.

@jepler
Copy link

jepler commented Sep 7, 2022

Besides what others in this thread have learned, I found that the problem exists when using an up to date setuptools but does not occur when using the python3-setuptools package provided by debian/ubuntu. This makes me think pypa/setuptools#3278 is related to the problem.

What I'm unsure of is, doesn't virtualenv have a contract with its consumers that (regardless of the details of the Python it's creating an environment for) <env>/bin/activate, <env>/bin/python and so forth exist?

Edited to add: I guess this is not the case, since Windows uses "Scripts":

For a list of shells we provide activators see activators. The location of these is right alongside the python executables ( usually Scripts folder on Windows, bin on POSIX), and are named as activate (and some extension that’s specific per activator; no extension is bash). You can invoke them, usually by source-ing (the source command might vary by shell - e.g. bash is .):

@stefanor
Copy link
Contributor

I'm just going to cc @stefanor here and hope they will see it (the previous comment).

Sorry, I missed this ping. I just found the bug via the commit in virtualenv. I was debugging this from the other end.

The ideal way to raise Debian issues is to file bugs in Debian's bugtracker. But also, feel free to email me / ping me on IRC / discord.

yugawara pushed a commit to cynic-net/pactivate that referenced this issue Sep 21, 2022
*** Tests (all manual so far):

- Ubuntu 22.04 / python3 3.10 / NO python3-distutils:   ** problem fixed
- Ubuntu 22.04 / python3 3.10 / WITH python3-distutils: ** still working
- Debian 11 / python3 3.10 / WITH python3-distutils:    ** still working
- Debian 11 / python3 3.10 / WITHOUT python3-distutils: ** ok error msg

*** Bugs in previous code:

- Deb 11 w/o python3-distutils fails to install bootstrap pip, prints a
  message, and should stop, but instead goes on with "Installing
  bootstrap virtualenv".
- Also separate commit to add commented-out "head-of-main" thing below.

*** Changes since last good commit (some need to be moved to other commits)

- pactivate:
  - Add commented-out "head of main" package for virtualenv
    - XXX move to a separate commit
  - add DEB_PYTHON_INSTALL_LAYOUT workaround
- cont-test:
  - remove the debugging
  - XXX keep a check for pactivate failure:
      (. ./$pactivate) || fail "pactivate failed: return code $?"
  - XXX keep large comment about system python 3.10.x

*** Stuff to document

    print(sysconfig.get_default_scheme())

    [2350]: pypa/virtualenv#2350
    [au 1415153]: https://askubuntu.com/a/1415153/354600

    [2415]: https://github.com/pypa/virtualenv/pull/2415/files?diff=unified&w=0

*** Maybe document

    pypa/setuptools#3278
0cjs added a commit to cynic-net/pactivate that referenced this issue Sep 21, 2022
*** Tests (all manual so far):

- Ubuntu 22.04 / python3 3.10 / NO python3-distutils:   ** problem fixed
- Ubuntu 22.04 / python3 3.10 / WITH python3-distutils: ** still working
- Debian 11 / python3 3.10 / WITH python3-distutils:    ** still working
- Debian 11 / python3 3.10 / WITHOUT python3-distutils: ** ok error msg

*** To-do:

- Discuss what we want to do for testing of the workaround. Currently we
  test only in debian:11, which confirms that the workaround does not
  affect that (where it's not needed) but does _not_ confirm that the
  workaround does work where it is needed (ubuntu:22.04 w/o
  python3-distutils).

*** Bugs in previous code:

- Deb 11 w/o python3-distutils fails to install bootstrap pip, prints a
  message, and should stop, but instead goes on with "Installing
  bootstrap virtualenv".
- Also separate commit to add commented-out "head-of-main" thing below.

*** Changes since last good commit (some need to be moved to other commits)

- pactivate:
  - Add commented-out "head of main" package for virtualenv
    - XXX move to a separate commit
  - add DEB_PYTHON_INSTALL_LAYOUT workaround
- cont-test:
  - remove the debugging
  - XXX keep a check for pactivate failure:
      (. ./$pactivate) || fail "pactivate failed: return code $?"
  - XXX keep large comment about system python 3.10.x

*** Stuff to document

    print(sysconfig.get_default_scheme())

    [2350]: pypa/virtualenv#2350
    [au 1415153]: https://askubuntu.com/a/1415153/354600

    [2415]: https://github.com/pypa/virtualenv/pull/2415/files?diff=unified&w=0

*** Maybe document

    pypa/setuptools#3278
yugawara pushed a commit to cynic-net/pactivate that referenced this issue Sep 22, 2022
*** Tests (all manual so far):

- Ubuntu 22.04 / python3 3.10 / NO python3-distutils:   ** problem fixed
- Ubuntu 22.04 / python3 3.10 / WITH python3-distutils: ** still working
- Debian 11 / python3 3.10 / WITH python3-distutils:    ** still working
- Debian 11 / python3 3.10 / WITHOUT python3-distutils: ** ok error msg

*** To-do:

- Discuss what we want to do for testing of the workaround. Currently we
  test only in debian:11, which confirms that the workaround does not
  affect that (where it's not needed) but does _not_ confirm that the
  workaround does work where it is needed (ubuntu:22.04 w/o
  python3-distutils).

*** Bugs in previous code:

- Deb 11 w/o python3-distutils fails to install bootstrap pip, prints a
  message, and should stop, but instead goes on with "Installing
  bootstrap virtualenv".
- Also separate commit to add commented-out "head-of-main" thing below.

*** Changes since last good commit (some need to be moved to other commits)

- pactivate:
  - Add commented-out "head of main" package for virtualenv
    - XXX move to a separate commit
  - add DEB_PYTHON_INSTALL_LAYOUT workaround
- cont-test:
  - remove the debugging
  - XXX keep a check for pactivate failure:
      (. ./$pactivate) || fail "pactivate failed: return code $?"
  - XXX keep large comment about system python 3.10.x

*** Stuff to document

    print(sysconfig.get_default_scheme())

    [2350]: pypa/virtualenv#2350
    [au 1415153]: https://askubuntu.com/a/1415153/354600

    [2415]: https://github.com/pypa/virtualenv/pull/2415/files?diff=unified&w=0

*** Maybe document

    pypa/setuptools#3278
yugawara pushed a commit to cynic-net/pactivate that referenced this issue Sep 22, 2022
*** Tests (all manual so far):

                  ----- Debian package ------
    Tested on     python3   python3-distutils   result after fix
    ──────────────────────────────────────────────────────────────────────
    Ubuntu 22.04   3.10        NO               problem fixed
    Ubuntu 22.04   3.10        YES              still working
    Debian 11      3.9         YES              still working
    Debian 11      3.9         NO               fails with clear message

*** To-do:

- Discuss what we want to do for testing of the workaround. Currently we
  test only in debian:11, which confirms that the workaround does not
  affect that (where it's not needed) but does _not_ confirm that the
  workaround does work where it is needed (ubuntu:22.04 w/o
  python3-distutils).

*** Bugs in previous code:

- Deb 11 w/o python3-distutils fails to install bootstrap pip, prints a
  message, and should stop, but instead goes on with "Installing
  bootstrap virtualenv".
- Also separate commit to add commented-out "head-of-main" thing below.

*** Changes since last good commit (some need to be moved to other commits)

- pactivate:
  - Add commented-out "head of main" package for virtualenv
    - XXX move to a separate commit
  - add DEB_PYTHON_INSTALL_LAYOUT workaround
- cont-test:
  - remove the debugging
  - XXX keep a check for pactivate failure:
      (. ./$pactivate) || fail "pactivate failed: return code $?"
  - XXX keep large comment about system python 3.10.x

*** Stuff to document

    print(sysconfig.get_default_scheme())

    [2350]: pypa/virtualenv#2350
    [au 1415153]: https://askubuntu.com/a/1415153/354600

    [2415]: https://github.com/pypa/virtualenv/pull/2415/files?diff=unified&w=0

*** Maybe document

    pypa/setuptools#3278
espressif-bot pushed a commit to espressif/esp-idf that referenced this issue Oct 17, 2022
On Ubuntu 22.04 virtualenv with the latest setuptools produces
environments with Python in "local/bin" instead of "bin" (see
pypa/virtualenv#2350).

Closes #9931
espressif-bot pushed a commit to espressif/esp-idf that referenced this issue Oct 17, 2022
On Ubuntu 22.04 virtualenv with the latest setuptools produces
environments with Python in "local/bin" instead of "bin" (see
pypa/virtualenv#2350).

Closes #9931
espressif-bot pushed a commit to espressif/esp-idf that referenced this issue Oct 19, 2022
On Ubuntu 22.04 virtualenv with the latest setuptools produces
environments with Python in "local/bin" instead of "bin" (see
pypa/virtualenv#2350).

Closes #9931
github-actions bot added a commit to MaRDI4NFDI/open-interfaces that referenced this issue Oct 31, 2022
Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.16.5 to
20.16.6.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst">virtualenv's
changelog</a>.</em></p>
<blockquote>
<h2>v20.16.6 (2022-10-25)</h2>
<p>Features - 20.16.6</p>
<pre><code>- Drop unneeded shims for PyPy3 directory structure
(`[#2426](pypa/virtualenv#2426)
&lt;https://github.com/pypa/virtualenv/issues/2426&gt;`_)
<p>Bugfixes - 20.16.6
</code></pre></p>
<ul>
<li>Fix selected scheme on debian derivatives for python 3.10 when
<code>python3-distutils</code> is not installed or the <code>venv</code>
scheme is not avaiable - by :user:<code>asottile</code>.
(<code>[#2350](pypa/virtualenv#2350)
&lt;https://github.com/pypa/virtualenv/issues/2350&gt;</code>_)</li>
<li>Allow the test suite to pass even with the original C shell (rather
than <code>tcsh</code>) - by :user:<code>kulikjak</code>.
(<code>[#2418](pypa/virtualenv#2418)
&lt;https://github.com/pypa/virtualenv/issues/2418&gt;</code>_)</li>
<li>Fix fallback handling of downloading wheels for bundled packages -
by :user:<code>schaap</code>.
(<code>[#2429](pypa/virtualenv#2429)
&lt;https://github.com/pypa/virtualenv/issues/2429&gt;</code>_)</li>
<li>Upgrade embedded setuptools to <code>65.5.0</code> from
<code>65.3.0</code> and pip to <code>22.3</code> from
<code>22.2.2</code> - by :user:<code>gaborbernat</code>.
(<code>[#2434](pypa/virtualenv#2434)
&lt;https://github.com/pypa/virtualenv/issues/2434&gt;</code>_)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pypa/virtualenv/commit/26f68e205dfbe36c47fdd1886b0c0060024dbeec"><code>26f68e2</code></a>
release 20.16.6</li>
<li><a
href="https://github.com/pypa/virtualenv/commit/b4564569171628ee839e14853a00f296686cae6a"><code>b456456</code></a>
Upgrade pip and setuptools (<a
href="https://github-redirect.dependabot.com/pypa/virtualenv/issues/2434">#2434</a>)</li>
<li><a
href="https://github.com/pypa/virtualenv/commit/3cff34f7dc46d9ad147a3d70df31e75cab77612d"><code>3cff34f</code></a>
Remove outdated PyPy stdlib overrides (<a
href="https://github-redirect.dependabot.com/pypa/virtualenv/issues/2426">#2426</a>)</li>
<li><a
href="https://github.com/pypa/virtualenv/commit/ae2594c5a822f62964f2ccef7832c26306bc66b1"><code>ae2594c</code></a>
Fix test_csh when running with the original csh (<a
href="https://github-redirect.dependabot.com/pypa/virtualenv/issues/2418">#2418</a>)</li>
<li><a
href="https://github.com/pypa/virtualenv/commit/cdf4225c689150010af8da1cc913e8f32bee06d2"><code>cdf4225</code></a>
Allow empty string as version for <code>find_compatible_in_house</code>
(<a
href="https://github-redirect.dependabot.com/pypa/virtualenv/issues/2430">#2430</a>)</li>
<li><a
href="https://github.com/pypa/virtualenv/commit/3ed75b25cc0c318fc789938bf6bad9c8326da739"><code>3ed75b2</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://github-redirect.dependabot.com/pypa/virtualenv/issues/2423">#2423</a>)</li>
<li><a
href="https://github.com/pypa/virtualenv/commit/445a68dffa7ba5c0af3b02ec0545b760cd8c04ba"><code>445a68d</code></a>
fix building python3.10 virtualenvs on debian derivatives (<a
href="https://github-redirect.dependabot.com/pypa/virtualenv/issues/2415">#2415</a>)</li>
<li><a
href="https://github.com/pypa/virtualenv/commit/56003ce62101c3d2cfe1a8eb82ef7defbe0d138f"><code>56003ce</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/pypa/virtualenv/issues/2413">#2413</a>
from pypa/release-20.16.5</li>
<li>See full diff in <a
href="https://github.com/pypa/virtualenv/compare/20.16.5...20.16.6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=virtualenv&package-manager=pip&previous-version=20.16.5&new-version=20.16.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
espressif-bot pushed a commit to espressif/esp-idf that referenced this issue Nov 11, 2022
On Ubuntu 22.04 virtualenv with the latest setuptools produces
environments with Python in "local/bin" instead of "bin" (see
pypa/virtualenv#2350).

Closes #9931
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants