Skip to content

FileNotFoundError for pipx_shared.pth with pipx install --python and pyenv #334

@bhrutledge

Description

@bhrutledge

Describe the bug

I have pipx installed from Homebrew (yay!), as well as pyenv. When I run pipx install black, the resulting venv using the python3.7 interpreter from Homebrew. When I run pipx install --python python3.8 black (or any other version, with any other package), I get the error mentioned in the issue title and reproduced below.

How to reproduce

$ pipx install --verbose --python python3.8 black
pipx > (_package_name_from_spec:93): Determined package name: black
pipx > (_package_name_from_spec:94): Package name determined in 0.0s
pipx > (run_subprocess:108): running python3.8 -m venv --without-pip /Users/brian/.local/pipx/venvs/black

pipx > (rmdir:18): removing directory /Users/brian/.local/pipx/venvs/black
Traceback (most recent call last):
  File "/usr/local/Cellar/pipx/0.15.1.1/libexec/bin/pipx", line 11, in <module>
    load_entry_point('pipx==0.15.1.1', 'console_scripts', 'pipx')()
  File "/usr/local/Cellar/pipx/0.15.1.1/libexec/lib/python3.7/site-packages/pipx/main.py", line 590, in cli
    return run_pipx_command(parsed_pipx_args)
  File "/usr/local/Cellar/pipx/0.15.1.1/libexec/lib/python3.7/site-packages/pipx/main.py", line 172, in run_pipx_command
    include_dependencies=args.include_deps,
  File "/usr/local/Cellar/pipx/0.15.1.1/libexec/lib/python3.7/site-packages/pipx/commands/commands.py", line 62, in install
    venv.create_venv(venv_args, pip_args)
  File "/usr/local/Cellar/pipx/0.15.1.1/libexec/lib/python3.7/site-packages/pipx/venv.py", line 139, in create_venv
    pipx_pth.write_text(f"{shared_libs.site_packages}\n", encoding="utf-8")
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py", line 1235, in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py", line 1203, in open
    opener=self._opener)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py", line 1058, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/brian/.local/pipx/venvs/black/lib/python3.7/site-packages/pipx_shared.pth'

$ pipx --version
0.15.1.1

$ pyenv version
3.8.0 (set by /Users/brian/.pyenv/version)
2.7.15 (set by /Users/brian/.pyenv/version)
3.7.4 (set by /Users/brian/.pyenv/version)
3.6.9 (set by /Users/brian/.pyenv/version)

$ pyenv which python3.8
/Users/brian/.pyenv/versions/3.8.0/bin/python3.8

Expected behavior

pipx should install a package using the python3.8 interpreter from pyenv.

I get the same error using an absolute path with --python $(pyenv which python3.8), but --python $(brew --prefix python@3.8)/bin/python3 works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions