Skip to content

Commit

Permalink
setup-python: fix pipx errors
Browse files Browse the repository at this point in the history
pipx now uses .local, and it seems if the old `Library/Application Support/pipx` location exists, everything falls apart, so remove the old location as well as the new preferred one (as usual) before reinstalling

solves these errors:

```
< 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'katcr' >
⚠️ Found a space in the home path. We heavily discourage this, due to multiple
    incompatibilities. Please check our docs for more information on this, as
    well as some pointers on how to migrate to a different home path.
creating virtual environment...
⚠️  Not removing existing venv /Users/balupton/Library/Application
    Support/pipx/venvs/katcr because it was not created in this session
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/__main__.py", line 14, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 1149, in cli
    return run_pipx_command(parsed_pipx_args, subparsers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 267, in run_pipx_command
    return commands.install(
           ^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/commands/install.py", line 92, in install
    venv.create_venv(venv_args, pip_args, override_shared)
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/venv.py", line 172, in create_venv
    pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 132, in get_site_packages
    output = run_subprocess(
             ^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 183, in run_subprocess
    completed_process = subprocess.run(
                        ^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/balupton/Library/Application Support/pipx/venvs/katcr/bin/python'
Installing to existing venv 'katcr'

</ 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'katcr' >[1]
< 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'poetry' >
⚠️ Found a space in the home path. We heavily discourage this, due to multiple
    incompatibilities. Please check our docs for more information on this, as
    well as some pointers on how to migrate to a different home path.
creating virtual environment...
⚠️  Not removing existing venv /Users/balupton/Library/Application
    Support/pipx/venvs/poetry because it was not created in this session
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/__main__.py", line 14, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 1149, in cli
    return run_pipx_command(parsed_pipx_args, subparsers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 267, in run_pipx_command
    return commands.install(
           ^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/commands/install.py", line 92, in install
    venv.create_venv(venv_args, pip_args, override_shared)
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/venv.py", line 172, in create_venv
    pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 132, in get_site_packages
    output = run_subprocess(
             ^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 183, in run_subprocess
    completed_process = subprocess.run(
                        ^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/balupton/Library/Application Support/pipx/venvs/poetry/bin/python'
Installing to existing venv 'poetry'

</ 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'poetry' >[1]
< 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'stig' >
⚠️ Found a space in the home path. We heavily discourage this, due to multiple
    incompatibilities. Please check our docs for more information on this, as
    well as some pointers on how to migrate to a different home path.
creating virtual environment...
⚠️  Not removing existing venv /Users/balupton/Library/Application
    Support/pipx/venvs/stig because it was not created in this session
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/__main__.py", line 14, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 1149, in cli
    return run_pipx_command(parsed_pipx_args, subparsers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 267, in run_pipx_command
    return commands.install(
           ^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/commands/install.py", line 92, in install
    venv.create_venv(venv_args, pip_args, override_shared)
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/venv.py", line 172, in create_venv
    pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 132, in get_site_packages
    output = run_subprocess(
             ^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 183, in run_subprocess
    completed_process = subprocess.run(
                        ^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/balupton/Library/Application Support/pipx/venvs/stig/bin/python'
Installing to existing venv 'stig'

</ 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'stig' >[1]
< 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'youtube_dl' >
⚠️ Found a space in the home path. We heavily discourage this, due to multiple
    incompatibilities. Please check our docs for more information on this, as
    well as some pointers on how to migrate to a different home path.
creating virtual environment...
⚠️  Not removing existing venv /Users/balupton/Library/Application
    Support/pipx/venvs/youtube-dl because it was not created in this session
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/__main__.py", line 14, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 1149, in cli
    return run_pipx_command(parsed_pipx_args, subparsers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 267, in run_pipx_command
    return commands.install(
           ^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/commands/install.py", line 92, in install
    venv.create_venv(venv_args, pip_args, override_shared)
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/venv.py", line 172, in create_venv
    pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 132, in get_site_packages
    output = run_subprocess(
             ^^^^^^^^^^^^^^^
  File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 183, in run_subprocess
    completed_process = subprocess.run(
                        ^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/balupton/Library/Application Support/pipx/venvs/youtube-dl/bin/python'
Installing to existing venv 'youtube-dl'

</ 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'youtube_dl' >[1]
```
  • Loading branch information
balupton committed Aug 8, 2024
1 parent 84df70a commit fa4fe01
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion commands/setup-python
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ function setup_python() (
if test "$python_version" -eq 3; then
# install pipx
echo-style --h3='install pipx'
fs-rm --quiet --no-confirm -- "$HOME/.local/pipx" # fix: Not removing existing venv /Users/balupton/.local/pipx/venvs/youtube-dl because it was not created in this session
# fix: Not removing existing venv /Users/balupton/.local/pipx/venvs/youtube-dl because it was not created in this session
fs-rm --quiet --no-confirm -- "$HOME/.local/pipx" "$HOME/Library/Application Support/pipx"
eval-helper --quiet \
-- "$bin" -m \
pip install --user --break-system-packages --upgrade --force-reinstall --no-warn-script-location \
Expand Down

0 comments on commit fa4fe01

Please sign in to comment.