Kubernetes 이야기

Ubuntu에서 pipenv 실행 시 FileNotFoundError 오류 본문

개발/python

Ubuntu에서 pipenv 실행 시 FileNotFoundError 오류

kmaster 2023. 1. 28. 23:41
반응형

Ubuntu 22.04에서 pipenv로 venv 생성 시 아래의 오류가 발생함.

 

# pipenv --python 3.11
Creating a virtualenv for this project...
Pipfile: /root/kopf/Pipfile
Using /bin/python (3.11.1) to create virtualenv...
⠹ Creating virtual environment...created virtual environment CPython3.11.1.final.0-64 in 179ms
  creator CPython3Posix(dest=/root/.local/share/virtualenvs/kopf-cdlYO4Rx, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/root/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment!
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/cli/options.py", line 57, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/vendor/click/core.py", line 1637, in invoke
    super().invoke(ctx)
  File "/usr/local/lib/python3.11/dist-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/vendor/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/cli/command.py", line 210, in cli
    ensure_project(
  File "/usr/local/lib/python3.11/dist-packages/pipenv/core.py", line 541, in ensure_project
    ensure_virtualenv(
  File "/usr/local/lib/python3.11/dist-packages/pipenv/core.py", line 474, in ensure_virtualenv
    do_create_virtualenv(
  File "/usr/local/lib/python3.11/dist-packages/pipenv/core.py", line 1060, in do_create_virtualenv
    project._environment = Environment(
                           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/environment.py", line 79, in __init__
    self._base_paths = self.get_paths()
                       ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/environment.py", line 383, in get_paths
    c = subprocess_run(command)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pipenv/utils/processes.py", line 75, in subprocess_run
    return subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/root/.local/share/virtualenvs/kopf-cdlYO4Rx/bin/python'

 

[원인]

python 디렉토리가 ~/.../local/bin/python 이어야 하는데 ~/.../bin/python으로 나타남.

 

[해결]

OS 별로 다르다는 이야기가 있는데 다음과 같이 해결함.

pip install virtualenv --upgrade^C

 

참고

https://github.com/pypa/pipenv/issues/5101

 

pipenv create virtual env error · Issue #5101 · pypa/pipenv

Be sure to check the existing issues (both open and closed!), and make sure you are running the latest version of Pipenv. Check the diagnose documentation for common issues before posting! We may c...

github.com

https://github.com/pypa/pipenv/issues/5109

 

Pipenv searches virtual environment's python binary in wrong path · Issue #5109 · pypa/pipenv

Hello, I'm having trouble using Pipenv lately. In particular, after I updated my OS (Fedora 36), pipenv during the install command tries to search the python binary inside {local_virtualenv}/lo...

github.com

 

반응형

'개발 > python' 카테고리의 다른 글

Kopf ( 예제 )  (1) 2023.02.05
Kopf (소개)  (0) 2023.02.03
Loguru  (0) 2023.01.24
Fastapi 모범 사례  (0) 2023.01.22
fastapi 개발 환경 구성  (0) 2023.01.22
Comments