Package: python3.10
Version: 3.10.9-1
Severity: normal
X-Debbugs-Cc: gusmachine+deb...@gmail.com

Dear Maintainer,

When I tried to create a python3 venv environment, I got an error message
"Error: name 'cmd' is not defined" and got partially-created venv environment.

Steps I did:
- Ran ` $ python3 -m venv venv ` to create a venv directory under the
  current directory, without installing python3-venv.

Expected:
- Have an error message "The virtual environment was not created successfully
  because ensurepip is not available."

Actual:
- Got an error message "Error: name 'cmd' is not defined" instead.

I found the following code snippet in /usr/lib/python3.10/venv/__init__.py
is suspicious. It uses a variable 'cmd' without defining it.

>     def _setup_pip(self, context):
>         """Installs or upgrades pip in a virtual environment"""
>         try:
>             self._call_new_python(context, '-m', 'ensurepip', '--upgrade',
>                                   '--default-pip', stderr=subprocess.STDOUT)
>         except subprocess.CalledProcessError:
>             stdlib = sysconfig.get_path('stdlib')
>             if not os.path.exists(f'{stdlib}/ensurepip/__main__.py'):
>                 print("""\
> The virtual environment was not created successfully because ensurepip is not
> available.  On Debian/Ubuntu systems, you need to install the python3-venv
> package using the following command.
> 
>     apt install python{}-venv
> 
> You may need to use sudo with that command.  After installing the python3-venv
> package, recreate your virtual environment.
> 
> Failing command: {}
> """.format(sysconfig.get_python_version(), cmd))
>                 sys.exit(1)

I installed python3-venv and now venv works for me.
But I'd be glad if I could get the correct error message.

Thanks,

-- System Information:
Debian Release: bookworm/sid
  APT prefers stable-security
  APT policy: (500, 'stable-security'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.0.0-5-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages python3.10 depends on:
ii  libpython3.10-stdlib  3.10.9-1
ii  media-types           8.0.0
ii  mime-support          3.66
ii  python3.10-minimal    3.10.9-1

python3.10 recommends no packages.

Versions of packages python3.10 suggests:
ii  binutils         2.39.50.20221208-5
pn  python3.10-doc   <none>
ii  python3.10-venv  3.10.9-1

-- no debconf information

Reply via email to