litex icon indicating copy to clipboard operation
litex copied to clipboard

Pip issues when installing Litex

Open GuzTech opened this issue 1 year ago • 7 comments

I tried to run ./litex_setup.py --init --user -config=full on a fully updated Arch box and during the installation of Git repositories step, I get the following error:

./litex_setup.py --install --user --config=full
          __   _ __      _  __         
         / /  (_) /____ | |/_/         
        / /__/ / __/ -_)>  <           
       /____/_/\__/\__/_/|_|         
     Build your hardware, easily!      
          LiteX Setup utility.         

[   0.001] LiteX Setup auto-update...
[   0.403] LiteX Setup is up to date.
[   0.404] Installing Git repositories...
[   0.404] ------------------------------
[   0.404] Installing migen Git repository...
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    python-xyz', where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Arch-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-Arch packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Traceback (most recent call last):
  File "/home/oguz/Software/litex/./litex_setup.py", line 480, in <module>
    main()
  File "/home/oguz/Software/litex/./litex_setup.py", line 460, in main
    litex_setup_install_repos(config=args.config, user_mode=args.user)
  File "/home/oguz/Software/litex/./litex_setup.py", line 285, in litex_setup_install_repos
    subprocess.check_call("\"{python3}\" -m pip install --editable . {options}".format(
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '"/usr/bin/python3" -m pip install --editable . --user' returned non-zero exit status 1.

So apparently some things with pip have changed and the recommended way to install packages is to use pipx instead. I have modified the litex_setup.py script to use pipx but then I get the following issue:

/litex_setup.py --install --user --config=full
          __   _ __      _  __         
         / /  (_) /____ | |/_/         
        / /__/ / __/ -_)>  <           
       /____/_/\__/\__/_/|_|         
     Build your hardware, easily!      
          LiteX Setup utility.         

[   0.001] Installing Git repositories...
[   0.001] ------------------------------
[   0.001] Installing migen Git repository...

No apps associated with package migen or its dependencies. If you are attempting to install a library, pipx should not be used. Consider using pip or a similar tool instead.
Traceback (most recent call last):
  File "/home/oguz/Software/litex/./litex_setup.py", line 484, in <module>
    main()
  File "/home/oguz/Software/litex/./litex_setup.py", line 464, in main
    litex_setup_install_repos(config=args.config, user_mode=args.user)
  File "/home/oguz/Software/litex/./litex_setup.py", line 289, in litex_setup_install_repos
    subprocess.check_call("\"{python3}\" -m pipx install --editable . {options}".format(
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '"/usr/bin/python3" -m pipx install --editable . ' returned non-zero exit status 1.

I can actually install packages with pipx, but since (in this case) Migen is not an application, pipx returns with error code 1. So I have modified the script further to not check the return code and with that change it now also installs properly. The relevant hacky changes to litex_setup.py can be found here: https://github.com/GuzTech/litex/compare/master...pipx-patch

GuzTech avatar Jun 22 '23 08:06 GuzTech