question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] setuptools>=60.0.0 causes virtualenv to create abnormal tree structure on ubuntu 22.04

See original GitHub issue

setuptools version

setuptools 60, 61, 62

59.x was the last version I found to not cause trouble. This also happens to be the default version installed with ubuntu 22.04 via apt.

Python version

Python 3.10

OS

Ubuntu 22.04

Also, I was unable to reproduce this on python:3.10-buster

Additional environment information

No response

Description

Installing setuptools==62.1.0 causes virtualenv venv to create an abnormal directory structure. Uninstalling setuptools solves the problem. This is 100% reproducible in ubuntu:22.04 docker image (ubuntu@sha256:06b5d30fabc1fc574f2ecab87375692299d45f8f190d9b71f512deb494114e1f)

The failure of virtualenv also affects poetry, which has no error checking for venv activate and will attempt to modify system packages when it thinks the venv is activated but it is not.

Without setuptools, venv/bin exists. With setuptools, venv/local/bin exists and no venv/bin dir exists.

Expected behavior

Setuptools does not interfere with virtualenv directory structure.

How to Reproduce

  1. Create Dockerfile:
    FROM ubuntu:22.04
    
    RUN apt-get update
    RUN apt-get install -y python3 python3-pip python3-virtualenv tree
    RUN pip install setuptools==62.1.0 ; \
        virtualenv venv ; \
        tree -L 3 venv ; \
        . venv/bin/activate
    
  2. Build it.
  3. Notice error.

Output

$ cat Dockerfile
FROM ubuntu:22.04

RUN apt-get update
RUN apt-get install -y python3 python3-pip python3-virtualenv tree
RUN pip install setuptools==62.1.0 ; \
    virtualenv venv ; \
    tree -L 3 venv ; \
    . venv/bin/activate
$ docker build -t test1 .
Sending build context to Docker daemon  24.01MB
Step 1/4 : FROM ubuntu:22.04
 ---> f0b07b45d05b
Step 2/4 : RUN apt-get update
 ---> Using cache
 ---> f3a881e3158b
Step 3/4 : RUN apt-get install -y python3 python3-pip python3-virtualenv tree
 ---> Using cache
 ---> 1b02afb3b2a1
Step 4/4 : RUN pip install setuptools==62.1.0 ;     virtualenv venv ;     tree -L 3 venv ;     . venv/bin/activate
 ---> Running in 5a7b54dc3a32
Collecting setuptools==62.1.0
  Downloading setuptools-62.1.0-py3-none-any.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 8.8 MB/s eta 0:00:00
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 59.6.0
    Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'setuptools'. No files were found to uninstall.
Successfully installed setuptools-62.1.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
created virtual environment CPython3.10.4.final.0-64 in 308ms
  creator CPython3Posix(dest=/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
    added seed packages: pip==22.0.2, setuptools==59.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
venv
|-- lib
|   `-- python3.10
|-- local
|   |-- bin
|   |   |-- activate
|   |   |-- activate.csh
|   |   |-- activate.fish
|   |   |-- activate.nu
|   |   |-- activate.ps1
|   |   |-- activate_this.py
|   |   |-- deactivate.nu
|   |   |-- pip
|   |   |-- pip-3.10
|   |   |-- pip3
|   |   |-- pip3.10
|   |   |-- python -> /usr/bin/python3
|   |   |-- python3 -> python
|   |   |-- python3.10 -> python
|   |   |-- wheel
|   |   |-- wheel-3.10
|   |   |-- wheel3
|   |   `-- wheel3.10
|   `-- lib
|       `-- python3.10
`-- pyvenv.cfg

6 directories, 19 files
/bin/sh: 1: .: cannot open venv/bin/activate: No such file
The command '/bin/sh -c pip install setuptools==62.1.0 ;     virtualenv venv ;     tree -L 3 venv ;     . venv/bin/activate' returned a non-zero code: 2

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:13
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
epomatticommented, May 3, 2022

Having this issue on WSL Ubuntu 22.04. This export SETUPTOOLS_USE_DISTUTILS=stdlib works around the issue.

3reactions
jeplercommented, Oct 25, 2022

I’ve filed a bug with Debian about this problem, since as far as I can tell nobody explicitly informed them that there is a problem: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1022749

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug #1968755 “venv doesn't work” : Bugs : python3.10 package
There's something wrong with Python 3.10 on Ubuntu 22.04. I'm pulling my hair out, but can't figure out what's going wrong. I condensed...
Read more >
I am unable to create a new virtualenv in ubuntu?
I had a similar experience. The reason for this is that I did it by installing two virtualenv with apt and pip3. pip3...
Read more >
Ubuntu Manpage: virtualenv - create virtual Python instances
virtualenv creates virtual Python executables, each of which can have its own set of ... The result is a directory containing its own...
Read more >
Virtualenv installs envs into local/bin instead of bin - Ask Ubuntu
The bin directory of my virtual environment produced with virtualenvwrapper (which uses virtualenv under the hood) is located in the subfolder ...
Read more >
How to Create Python Virtual Environment on Ubuntu 22.04
The venv package is available in Ubuntu repository. Let's first install venv package using the following command: apt install python3-venv. Now, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found