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

FileNotFoundError: [Errno 2] when installing pipenv from pipfile #5075

Closed
limkin092 opened this issue Apr 22, 2022 · 65 comments · Fixed by #5087
Closed

FileNotFoundError: [Errno 2] when installing pipenv from pipfile #5075

limkin092 opened this issue Apr 22, 2022 · 65 comments · Fixed by #5087
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged.

Comments

@limkin092
Copy link

limkin092 commented Apr 22, 2022

Hi all,

I am experiencing some issues while building my docker file on the last shown step (1):

COPY Pipfile* ./
RUN pip3 install pipenv
(1) RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy --clear --keep-outdated.

I get the following Stacktrace:

 > [builder-image 5/5] RUN pipenv install --deploy --clear --keep-outdated:                                                                                                                                                    
#10 1.527 Creating a virtualenv for this project...                                                                                                                                                                            
#10 1.527 Pipfile: /Pipfile                                                                                                                                                                                                    
#10 1.543 Using /usr/bin/python3 (3.10.4) to create virtualenv...                                                                                                                                                              
⠼ Creating virtual environment...created virtual environment CPython3.10.4.final.0-64 in 491ms                                                                                                                                 
#10 2.680   creator CPython3Posix(dest=/.venv, clear=False, no_vcs_ignore=False, global=False)
#10 2.680   seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
#10 2.680     added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
#10 2.680   activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
#10 2.680 
#10 2.758✔ Successfully created virtual environment! 
#10 2.760 Traceback (most recent call last):
#10 2.760   File "/usr/local/bin/pipenv", line 8, in <module>
#10 2.760     sys.exit(cli())
#10 2.760   File "/usr/local/lib/python3.10/dist-packages/pipenv/vendor/click/core.py", line 1128, in __call__
#10 2.761     return self.main(*args, **kwargs)
#10 2.761   File "/usr/local/lib/python3.10/dist-packages/pipenv/cli/options.py", line 56, in main
#10 2.761     return super().main(*args, **kwargs, windows_expand_args=False)
#10 2.761   File "/usr/local/lib/python3.10/dist-packages/pipenv/vendor/click/core.py", line 1053, in main
#10 2.761     rv = self.invoke(ctx)
#10 2.761   File "/usr/local/lib/python3.10/dist-packages/pipenv/vendor/click/core.py", line 1659, in invoke
#10 2.762     return _process_result(sub_ctx.command.invoke(sub_ctx))
#10 2.764   File "/usr/local/lib/python3.10/dist-packages/pipenv/vendor/click/core.py", line 1395, in invoke
#10 2.765     return ctx.invoke(self.callback, **ctx.params)
#10 2.765   File "/usr/local/lib/python3.10/dist-packages/pipenv/vendor/click/core.py", line 754, in invoke
#10 2.765     return __callback(*args, **kwargs)
#10 2.766   File "/usr/local/lib/python3.10/dist-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
#10 2.766     return ctx.invoke(f, obj, *args, **kwargs)
#10 2.766   File "/usr/local/lib/python3.10/dist-packages/pipenv/vendor/click/core.py", line 754, in invoke
#10 2.767     return __callback(*args, **kwargs)
#10 2.767   File "/usr/local/lib/python3.10/dist-packages/pipenv/cli/command.py", line 222, in install
#10 2.767     do_install(
#10 2.767   File "/usr/local/lib/python3.10/dist-packages/pipenv/core.py", line 1964, in do_install
#10 2.768     ensure_project(
#10 2.768   File "/usr/local/lib/python3.10/dist-packages/pipenv/core.py", line 552, in ensure_project
#10 2.770     ensure_virtualenv(
#10 2.770   File "/usr/local/lib/python3.10/dist-packages/pipenv/core.py", line 485, in ensure_virtualenv
#10 2.770     do_create_virtualenv(
#10 2.770   File "/usr/local/lib/python3.10/dist-packages/pipenv/core.py", line 1012, in do_create_virtualenv
#10 2.771     project._environment = Environment(
#10 2.772   File "/usr/local/lib/python3.10/dist-packages/pipenv/environment.py", line 70, in __init__
#10 2.772     self._base_paths = self.get_paths()
#10 2.773   File "/usr/local/lib/python3.10/dist-packages/pipenv/environment.py", line 394, in get_paths
#10 2.774     c = subprocess_run(command)
#10 2.774   File "/usr/local/lib/python3.10/dist-packages/pipenv/utils/processes.py", line 75, in subprocess_run
#10 2.774     return subprocess.run(
#10 2.775   File "/usr/lib/python3.10/subprocess.py", line 501, in run
#10 2.775     with Popen(*popenargs, **kwargs) as process:
#10 2.775   File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
#10 2.776     self._execute_child(args, executable, preexec_fn, close_fds,
#10 2.778   File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
#10 2.778     raise child_exception_type(errno_num, err_msg, err_filename)
#10 2.778 FileNotFoundError: [Errno 2] No such file or directory: '/.venv/bin/python'
------
executor failed running [/bin/sh -c pipenv install --deploy --clear --keep-outdated]: exit code: 1

The solution I found is:

COPY Pipfile* ./
RUN pip3 install pipenv==v2022.4.20
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy --clear --keep-outdated

The build image is ubuntu:22.04, python-version 3.10.4

@matteius
Copy link
Member

I don't think there should be a v in front of your version for 2022.4.20 on the solution line RUN pip3 install pipenv==v2022.4.20 -- not sure how that could work. That being said, @limkin092 are you saying your Dockerfile works on 2022.4.20 and no ton 2022.4.21?

@andrewdotn
Copy link

I am having the same issue on the new Ubuntu 22.04 but not the previous 21.10.

I do not understand the problem but I have identified a workaround: pip uninstall -y setuptools seems to allow pipenv to run.

I can reproduce the issue without pipenv. Something about the act of installing the setuptools dependency specified in pipenv’s setup.py breaks virtualenv creation on Ubuntu 22.04; no bin dir gets created.

FROM ubuntu:22.04

RUN apt update \
    && DEBIAN_FRONTEND=noninteractive apt install -y python3-pip \
    && rm -rf /var/lib/apt/lists

RUN adduser  user1

USER user1
WORKDIR /home/user1

RUN pip install --user virtualenv 'setuptools>=60.0.0'
RUN python3 -m virtualenv foo && foo/bin/python3 --version

fails with /bin/sh: 1: foo/bin/python3: not found

@ghost
Copy link

ghost commented Apr 23, 2022

same problem:
pipenv: version 2022.4.21
Ubuntu 22.04 LTS
Python 3.10.4

pipenv install requests
/usr/local/lib/python3.10/dist-packages/pkg_resources/__init__.py:123: PkgResourcesDeprecationWarning: 1.16.0-unknown 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(
/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(
Creating a virtualenv for this project...
Pipfile: /home/ubuntu/Downloads/Pipfile
Using /usr/bin/python3 (3.10.4) to create virtualenv...
⠧ Creating virtual environment...created virtual environment CPython3.10.4.final.0-64 in 185ms
  creator CPython3Posix(dest=/home/ubuntu/.local/share/virtualenvs/Downloads-UJGff8HK, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/ubuntu/.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 "/usr/local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.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/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.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/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.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/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/cli/command.py", line 222, in install
    do_install(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/core.py", line 1964, in do_install
    ensure_project(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/core.py", line 552, in ensure_project
    ensure_virtualenv(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/core.py", line 485, in ensure_virtualenv
    do_create_virtualenv(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/core.py", line 1012, in do_create_virtualenv
    project._environment = Environment(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/environment.py", line 70, in __init__
    self._base_paths = self.get_paths()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/environment.py", line 394, in get_paths
    c = subprocess_run(command)
  File "/home/ubuntu/.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/ubuntu/.local/share/virtualenvs/Downloads-UJGff8HK/bin/python'

what is see is virtualenv create complete other structure without bin

ls /home/ubuntu/.local/share/virtualenvs/Downloads-UJGff8HK/
lib  local  pyvenv.cfg

@nomis
Copy link

nomis commented Apr 23, 2022

This happens with setuptools>=60 on Ubuntu 22.04 with Python 3.10.4 but not on Ubuntu 20.04 with Python 3.8.10/3.9.5.

Downgrading setuptools to before version 60 works around the problem. Ubuntu 22.04 comes with version 59.6.0 but pipenv 2022.4.21 wants setuptools>=60.0.0.

@andrewdotn
Copy link

The (excellent!) bug report at pypa/setuptools#3278 identifies the cause more precisely.

There are two better workarounds identified there:

  • Set the environment variable SETUPTOOLS_USE_DISTUTILS=stdlib when running pipenv.
  • Or change the default setting in a file with sed -i.bak -e "s/var, 'local'/var, 'stdlib'/" ~/.local/lib/python3.10/site-packages/distutils-precedence.pth

@limkin092
Copy link
Author

@andrewdotn this worked for me :)
@matteius yes, from one day to other it did not work...

@felipecrp
Copy link

@andrewdotn the SETUPTOOLS_USE_DISTUTILS=stdlib also worked for me.

@matteius
Copy link
Member

@oz123 I am wondering what could have been different between 2022.4.20 and 2022.4.21 that might have caused this?

@matteius
Copy link
Member

Ah I forgot that I updated the minimum version of pip and setuptools when I dropped 3.6 support -- I think I based it on the versions that had dropped 3.6 support of those projects: https://github.com/pypa/pipenv/pull/5066/files#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7R26

archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Apr 26, 2022
- Added temporary requirements_downgrade.patch file to revert upstream
  requirements changes to what's available in Arch (at the time of writing).
  Upstream appears to have bumped requirements unintentionally. See:
    - pypa/pipenv#5075
    - pypa/pipenv#5075 (comment)

git-svn-id: file:///srv/repos/svn-community/svn@1191061 9fca08f4-af9d-4005-b8df-a31f2cc04f65
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Apr 26, 2022
- Added temporary requirements_downgrade.patch file to revert upstream
  requirements changes to what's available in Arch (at the time of writing).
  Upstream appears to have bumped requirements unintentionally. See:
    - pypa/pipenv#5075
    - pypa/pipenv#5075 (comment)


git-svn-id: file:///srv/repos/svn-community/svn@1191061 9fca08f4-af9d-4005-b8df-a31f2cc04f65
@epomatti
Copy link

@andrewdotn I had to export in order for it to work:

export SETUPTOOLS_USE_DISTUTILS=stdlib

@matteius
Copy link
Member

I would like some guidance on what the proper resolution would be for pipenv -- should we loosen the versions of setuptools in the setup.py? I am not convinced that we should allow such older versions of pip since we vendor in the latest pip, (I also thought we only used the pip internal to pipenv, and the fact that we use both I find troubling), anyway I am glad there is some work arounds, but I'd like to understand the path forward for this pipenv issue as well.

@nomis
Copy link

nomis commented Apr 27, 2022

I don't think the version of pip affects this?

When the setuptools/virtualenv/distutils bug is resolved then pipenv can depend on the newer version of those.

The difference between 2022.4.20 and 2022.4.21 is that it requires setuptools>=60 which has this problem. Ubuntu 22.04 was also released around the same time.

Foxboron pushed a commit to Foxboron/archlinux-pkgbuilds that referenced this issue Apr 27, 2022
@emmmhx
Copy link

emmmhx commented Apr 28, 2022

@andrewdotn trying to get rid of this warning:
/home/danka/.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
But the workaround you mentioned didn't solve it. Any ideas what's the issue here?

  • python 3.10.4
  • pip 22.0.4
  • pipenv, version 2022.4.21

@matteius
Copy link
Member

@emmmhx The deprecation warning shouldn't be causing an actual error ... is that 1.1build1 coming from your own package?

@nomis Ok sounds like a plan to open setuptools back up to the prior specifier.

@emmmhx
Copy link

emmmhx commented Apr 28, 2022

@matteius This warning appears every time I run pipenv in terminal.

@felipecrp
Copy link

I also have these warnings every time I run pipenv. Although the command works, the warnings are undesired.

I'm using unto 22.04 with WSL2.

@matteius
Copy link
Member

Can someone try this branch and see downgrading the setuptools specifier is enough? #5087

@felipecrp
Copy link

felipecrp commented Apr 28, 2022

@matteius Sure. I tested but it did not solve the problem.

I did the following commands:

$ pip uninstall pipenv
$ pip install "git+https://github.com/pypa/pipenv.git@issue-5075-setuptools"

Then, tried to create the env:

$ pipenv install

The result was:

/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/tmp/Pipfile
Using /usr/bin/python3 (3.10.4) to create virtualenv...
⠙ Creating virtual environment...created virtual environment CPython3.10.4.final.0-64 in 403ms
  creator CPython3Posix(dest=/home/user/.local/share/virtualenvs/tmp-K1LwcDUA, 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 <module>
    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 1965, in do_install
    ensure_project(
  File "/home/user/.local/lib/python3.10/site-packages/pipenv/core.py", line 553, in ensure_project
    ensure_virtualenv(
  File "/home/user/.local/lib/python3.10/site-packages/pipenv/core.py", line 486, in ensure_virtualenv
    do_create_virtualenv(
  File "/home/user/.local/lib/python3.10/site-packages/pipenv/core.py", line 1013, 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/tmp-K1LwcDUA/bin/python'

@andrewdotn
Copy link

@matteius Yup, that branch works for me when I change the pip install line in my test Dockerfile to @felipecrp’s pip install "git+https://github.com/pypa/pipenv.git@issue-5075-setuptools", and include a required apt install -y git.

@felipecrp Did you try that command on a fresh machine? Or maybe after first uninstalling setuptools? Installing just the updated pipenv in an environment that was already experiencing this issue won’t automatically downgrade or remove an updated setuptools.

@felipecrp
Copy link

felipecrp commented Apr 28, 2022

@andrewdotn @matteius If I uninstall setuptools, it works, but I still get the warnings.

$ pip uninstall pipenv
$ pip uninstall setuptools
$ pip install "git+https://github.com/pypa/pipenv.git@issue-5075-setuptools"
$ pipenv install

The command successfully creates the env, but still with some warnings.

/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 0.1.43ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: 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/tmp/Pipfile
Using /usr/bin/python3 (3.10.4) to create virtualenv...
⠸ Creating virtual environment...created virtual environment CPython3.10.4.final.0-64 in 202ms
  creator CPython3Posix(dest=/home/user/.local/share/virtualenvs/tmp-K1LwcDUA, 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/tmp-K1LwcDUA
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.

@nomis
Copy link

nomis commented Apr 28, 2022

Those warnings are nothing to do with pipenv.

They're coming from pkg_resources and would need to be reported to Ubuntu, but this warning has been present for several Ubuntu LTS releases now.

@felipecrp
Copy link

I don't know but I only see them when I run pipenv.

@matteius
Copy link
Member

@felipecrp its definitely been reported before the new versions about the warnings for pkg_resources. Here is an example, and there are a couple more if you search the closed issues: #4960

@felipecrp
Copy link

I believe that the pull request solves this issue. Thank you all for the help!

@khteh
Copy link

khteh commented Aug 6, 2022

It happens again even after I remove .local/share/virtualenvs/jupyter-notebooks-46_jCq9y:

$ pipenv --version
/home/khteh/.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(
/home/khteh/.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(
pipenv, version 2022.7.24
khteh@khteh-p17-2i:/usr/src/jupyter-notebooks 2020 $ pipenv shell
/home/khteh/.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(
/home/khteh/.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(
Creating a virtualenv for this project...
Pipfile: /usr/src/jupyter-notebooks/Pipfile
Using /usr/bin/python (3.10.4) to create virtualenv...
⠙ Creating virtual environment...created virtual environment CPython3.10.4.final.0-64 in 83ms
  creator CPython3Posix(dest=/home/khteh/.local/share/virtualenvs/jupyter-notebooks-46_jCq9y, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/khteh/.local/share/virtualenv)
    added seed packages: pip==22.1.2, setuptools==62.3.3, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment! 
Traceback (most recent call last):
  File "/home/khteh/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/khteh/.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/khteh/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/khteh/.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/khteh/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/khteh/.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/khteh/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/cli/command.py", line 435, in shell
    do_shell(
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/core.py", line 2444, in do_shell
    ensure_project(
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/core.py", line 553, in ensure_project
    ensure_virtualenv(
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/core.py", line 486, in ensure_virtualenv
    do_create_virtualenv(
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/core.py", line 1019, in do_create_virtualenv
    project._environment = Environment(
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/environment.py", line 72, in __init__
    self._base_paths = self.get_paths()
  File "/home/khteh/.local/lib/python3.10/site-packages/pipenv/environment.py", line 394, in get_paths
    c = subprocess_run(command)
  File "/home/khteh/.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/khteh/.local/share/virtualenvs/jupyter-notebooks-46_jCq9y/bin/python'
$ echo $SETUPTOOLS_USE_DISTUTILS
stdlib
$ ls ~/.local/share/virtualenvs/jupyter-notebooks-46_jCq9y/bin
ls: cannot access '/home/khteh/.local/share/virtualenvs/jupyter-notebooks-46_jCq9y/bin': No such file or directory

@khteh
Copy link

khteh commented Aug 6, 2022

Why is pipenv behaving so strange?

$ which pipenv
/usr/local/bin/pipenv
$ pipenv --version
bash: /home/khteh/.local/bin/pipenv: No such file or directory

@khteh
Copy link

khteh commented Aug 6, 2022

pipenv install --python=/path/to/python resoves it.

@dcriado
Copy link

dcriado commented Aug 31, 2022

I was getting the same FileNotFoundError alongwith two PkgResourcesDeprecationWarning.

See warnings
~/.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(
~/.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(

Searching for the origin of those warnings, I stumbled upon this StackOverflow question. Following the accepted answer, I downgraded setuptools from version 65.3.0 to version 58.3.0:

pip install --upgrade --user setuptools==58.3.0

After that, I rerun pipenv install and everything worked properly: a bin/python path was found within the virtualenvs directory, and no warnings were issued.

  • Ubuntu 22.04.1 LTS
  • Python 3.10.4
  • Pip 22.2.2
  • Pipenv 2022.8.24

@tonydattolo
Copy link

tonydattolo commented Sep 9, 2022

edit: workaround pip uninstall -y setuptools works. hopefully this doesn't break anything else. as referenced here: https://stackoverflow.com/a/72051453/11616858

__
still running into this issue

It looks like it is trying to graph the wrong executable location for the python interpreter. it is looking for /.venv/bin/python but it should be looking for /.venv/local/bin/python

Traceback (most recent call last):
  File "/home/tony/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/cli/options.py", line 57, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/tony/.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/tony/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/tony/.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/tony/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/cli/command.py", line 398, in shell
    do_shell(
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/core.py", line 2533, in do_shell
    ensure_project(
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/core.py", line 526, in ensure_project
    ensure_virtualenv(
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/core.py", line 459, in ensure_virtualenv
    do_create_virtualenv(
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/core.py", line 964, in do_create_virtualenv
    project._environment = Environment(
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/environment.py", line 80, in __init__
    self._base_paths = self.get_paths()
  File "/home/tony/.local/lib/python3.10/site-packages/pipenv/environment.py", line 391, in get_paths
    c = subprocess_run(command)
  File "/home/tony/.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/tony/repos/graphql-playground/backend/.venv/bin/python'
  • Ubuntu 22.04.1 LTS
  • Python 3.10.4
  • pipenv 2022.9.8
  • pip 22.2.2

@matteius matteius reopened this Sep 9, 2022
@matteius
Copy link
Member

The PkgResourcesDeprecationWarning were finally solved -- perhaps also the FileNotFoundError -- could someone re-check?

@matteius matteius added the Status: Awaiting Update ⏳ This issue requires more information before assistance can be provided. label Sep 22, 2022
@Reddine
Copy link

Reddine commented Sep 23, 2022

perhaps also the FileNotFoundError -- could someone re-check?

I still have to use #5075 (comment) solution.

  • Ubuntu 22.04.1 LTS
  • pipenv, version 2022.9.21
  • Python 3.10.6
  • pip 22.2.2

@matteius matteius added hacktoberfest Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. and removed Status: Awaiting Update ⏳ This issue requires more information before assistance can be provided. labels Sep 23, 2022
@matteius
Copy link
Member

I am now getting the same error now that I upgraded my Ubuntu VM (22.0.4) ... the export SETUPTOOLS_USE_DISTUTILS=stdlib workaround did not seem to help in my case.

@Reddine
Copy link

Reddine commented Sep 24, 2022

I am now getting the same error now that I upgraded my Ubuntu VM (22.0.4) ... the export SETUPTOOLS_USE_DISTUTILS=stdlib workaround did not seem to help in my case.

After installing Ubuntu I used this command to update pipenv
pip install --upgrade pipenv
and I have this shell configuration:

alias python=python3
export PATH="/home/MYUSERNAME/.local/bin:$PATH"

Not sure if that helps!

@matteius
Copy link
Member

The problem for making this better in pipenv is how to tell when it should be {base}/bin vs {base}/local/bin ... the way its coded right now is it referencing a specific scheme in sysconfig that ends up being wrong for ubuntu. I am not sure if this patch will have side-effects, but I started a branch to begin addressing this issue. #5376

@matteius
Copy link
Member

I spent some more time on this, and I think the best workaround, which is reflected in https://github.com/pypa/pipenv/pull/5376/files, is to use --creator=venv when pipenv creates new virtualenvs, this seems to solve all of the problems I found using pipenv out of the box on the latest ubuntu, but I think it may means once we release this, folks that are using the workaround would need to clear out those virtualenvs and let them be created fresh.

@oz123
Copy link
Contributor

oz123 commented Sep 25, 2022

Does this work if python3-venv package is missing?

@matteius
Copy link
Member

@oz123

matteius@matteius-VirtualBox:~/pipenv$ pip uninstall python3-venv
WARNING: Skipping python3-venv as it is not installed.
matteius@matteius-VirtualBox:~/pipenv$ pip uninstall python-venv
WARNING: Skipping python-venv as it is not installed.

@oz123
Copy link
Contributor

oz123 commented Sep 25, 2022

You need to check with apt:

$ sudo apt remove python3-venv

@matteius
Copy link
Member

@oz123 Appears to work:

matteius@matteius-VirtualBox:~/pipenv$ sudo apt remove python3-venv
[sudo] password for matteius: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  systemd-hwe-hwdb
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
  python3-venv
0 upgraded, 0 newly installed, 1 to remove and 17 not upgraded.
After this operation, 6,144 B disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 297188 files and directories currently installed.)
Removing python3-venv (3.10.6-1~22.04) ...
matteius@matteius-VirtualBox:~/pipenv$ pipenv --rm
Removing virtualenv (/home/matteius/.virtualenvs/pipenv-wR0g04D-)...
matteius@matteius-VirtualBox:~/pipenv$ pipenv sync -d
Creating a virtualenv for this project...
Pipfile: /home/matteius/pipenv/Pipfile
Using /usr/bin/python3 (3.10.6) to create virtualenv...
⠸ Creating virtual environment...created virtual environment CPython3.10.6.final.0-64 in 222ms
  creator Venv(dest=/home/matteius/.virtualenvs/pipenv-wR0g04D-, 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/matteius/.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

✔ Successfully created virtual environment! 
Virtualenv location: /home/matteius/.virtualenvs/pipenv-wR0g04D-
Installing dependencies from Pipfile.lock (ccf32d)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!
matteius@matteius-VirtualBox:~/pipenv$ pipenv shell
Launching subshell in virtual environment...
 . /home/matteius/.virtualenvs/pipenv-wR0g04D-/bin/activate
matteius@matteius-VirtualBox:~/pipenv$  . /home/matteius/.virtualenvs/pipenv-wR0g04D-/bin/activate
(pipenv-wR0g04D-) matteius@matteius-VirtualBox:~/pipenv$ 

@oz123
Copy link
Contributor

oz123 commented Sep 25, 2022

It appears that Ubuntu is distributing venv as part of the standard libpython ! It used to be a separate package in older times.

@kiprotichdominic
Copy link

THIS WORKED FOR ME

I'm still facing this issue in Ubuntu 22.04 too. Removing ~/.local/share/virtualenvs/ followed by export SETUPTOOLS_USE_DISTUTILS=stdlib works for me as a temporary workaround. Warnings are still there.

jixbo@thinkpad:~$ pip --version
pip 22.1.2 from /home/jixbo/.local/lib/python3.10/site-packages/pip (python 3.10)
jixbo@thinkpad:~$ python --version
Python 3.10.4
jixbo@thinkpad:~$ which python
/usr/bin/python

@matteius
Copy link
Member

Fix will be in the next release.

@yogenderPalChandra
Copy link

none of the above worked for me, what worked was simply removing the already created venv:
pipenv --rm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.