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

WSL 22.04 - Python 3.10 - pipenv does not work #8327

Closed
1 of 2 tasks
felipecrp opened this issue Apr 24, 2022 · 3 comments
Closed
1 of 2 tasks

WSL 22.04 - Python 3.10 - pipenv does not work #8327

felipecrp opened this issue Apr 24, 2022 · 3 comments

Comments

@felipecrp
Copy link

felipecrp commented Apr 24, 2022

Version

Microsoft Windows [Version 10.0.19044.1645]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.102.1

Distro Version

Ubuntu 22.04

Other Software

pipenv

Repro Steps

sudo apt update
sudo apt install python3-pip
pip installl pipenv
export PATH="/home/user/.local/bin:$PATH"
mkdir test
cd test
pipenv install

Expected Behavior

It was expected to create a pipenv environment with Python 3.10.

It works flawless in previous wsl python 20.04 and 20.10 (with python 3.10).

Actual Behavior

There is an error on pipenv and the environment is not created.

Diagnostic Logs

➜ ansible pipenv install
/home/user/.local/lib/python3.10/site-packages/pkg_resources/init.py:123: PkgResourcesDeprecationWarning: 0.1.43ubuntu1 is an invalid version and will not be supported in a future release
warnings.warn(
/home/user/.local/lib/python3.10/site-packages/pkg_resources/init.py:123: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
warnings.warn(
Creating a virtualenv for this project...
Pipfile: /home/user/ansible/Pipfile
Using /usr/bin/python3 (3.10.4) to create virtualenv...
⠙ Creating virtual environment...created virtual environment CPython3.10.4.final.0-64 in 405ms
creator CPython3Posix(dest=/home/user/.local/share/virtualenvs/ansible-U3vexcod, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/user/.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

✔ Successfully created virtual environment!
Traceback (most recent call last):
File "/home/user/.local/bin/pipenv", line 8, in
sys.exit(cli())
File "/home/user/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/pipenv/cli/options.py", line 56, in main
return super().main(*args, **kwargs, windows_expand_args=False)
File "/home/user/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/user/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/user/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/pipenv/cli/command.py", line 222, in install
do_install(
File "/home/user/.local/lib/python3.10/site-packages/pipenv/core.py", line 1964, in do_install
ensure_project(
File "/home/user/.local/lib/python3.10/site-packages/pipenv/core.py", line 552, in ensure_project
ensure_virtualenv(
File "/home/user/.local/lib/python3.10/site-packages/pipenv/core.py", line 485, in ensure_virtualenv
do_create_virtualenv(
File "/home/user/.local/lib/python3.10/site-packages/pipenv/core.py", line 1012, in do_create_virtualenv
project._environment = Environment(
File "/home/user/.local/lib/python3.10/site-packages/pipenv/environment.py", line 70, in init
self._base_paths = self.get_paths()
File "/home/user/.local/lib/python3.10/site-packages/pipenv/environment.py", line 394, in get_paths
c = subprocess_run(command)
File "/home/user/.local/lib/python3.10/site-packages/pipenv/utils/processes.py", line 75, in subprocess_run
return subprocess.run(
File "/usr/lib/python3.10/subprocess.py", line 501, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.10/subprocess.py", line 966, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.local/share/virtualenvs/ansible-U3vexcod/bin/python'

@elsaco
Copy link

elsaco commented Apr 24, 2022

@felipecrp the virtual environment is being created but can't be activated because the interpreter is located in <virt_env_name>/local/bin/. To manually activate your new environment use source /home/user/.local/share/virtualenvs/ansible-U3vexcod/local/bin/activate in the example above, until a fix will be provided.

Sample output:

tux@RIPPER:~/foo$ source /home/tux/.local/share/virtualenvs/foo-FuLOVPqO/local/bin/activate
(foo) tux@RIPPER:~/foo$ ls
(foo) tux@RIPPER:~/foo$ python
python             python3            python3-config     python3.10         python3.10-config
(foo) tux@RIPPER:~/foo$ python --version
Python 3.10.4
(foo) tux@RIPPER:~/foo$ which python
/home/tux/.local/share/virtualenvs/foo-FuLOVPqO/local/bin/python
(foo) tux@RIPPER:~/foo$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
(foo) tux@RIPPER:~$ deactivate
tux@RIPPER:~$

The issue is being tracked at pypa/pipenv#5075. The bug is in setuptools and is being tracked at pypa/setuptools#3278

@felipecrp
Copy link
Author

@elsaco Thank you for the response!

They posted a workaround in pypa/pipenv#5075 (comment). We can run pipenv using stdlib to create de environment:

$ SETUPTOOLS_USE_DISTUTILS=stdlib pipenv install

Which results in the creation of the virtualenv:


/usr/local/lib/python3.10/dist-packages/pkg_resources/init.py:123: PkgResourcesDeprecationWarning: 0.1.43ubuntu1 is an invalid version and will not be supported in a future release
warnings.warn(
/usr/local/lib/python3.10/dist-packages/pkg_resources/init.py:123: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
warnings.warn(
Creating a virtualenv for this project...
Pipfile: /home/user/test/Pipfile
Using /usr/bin/python3 (3.10.4) to create virtualenv...
⠸ Creating virtual environment...created virtual environment CPython3.10.4.final.0-64 in 174ms
creator CPython3Posix(dest=/home/user/.local/share/virtualenvs/test-ImYVRXb5, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/user/.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

✔ Successfully created virtual environment!
Virtualenv location: /home/user/.local/share/virtualenvs/test-ImYVRXb5
Creating a Pipfile for this project...
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (e4eef2)!
Installing dependencies from Pipfile.lock (e4eef2)...
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.


We just need to set SETUPTOOLS_USE_DISTUTILS to create the environment. Apparently, after the creation we can install packages and use pipenv.

Still, there are some warnings when we run pipenv:

/usr/local/lib/python3.10/dist-packages/pkg_resources/__init__.py:123: PkgResourcesDeprecationWarning: 0.1.43ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/local/lib/python3.10/dist-packages/pkg_resources/__init__.py:123: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
  warnings.warn(

@OneBlue
Copy link
Collaborator

OneBlue commented Apr 26, 2022

Closing since this is not a WSL issue

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

No branches or pull requests

3 participants