cht-conf icon indicating copy to clipboard operation
cht-conf copied to clipboard

Python error when installing pyxform medic on Linux

Open kennsippell opened this issue 11 months ago • 1 comments

Describe the bug Blocking error when using cht-conf for the first time to deploy a configuration

To Reproduce Steps to reproduce the behavior:

  1. Run npx cht --url=http://medic:password@localhost:5988
  2. User gets this error (expected)
ERROR There was a problem executing xls2xform.  It may not be installed.
E To install the latest pyxform, try one of the following:
E
E Ubuntu
E       sudo python -m pip install git+https://github.com/medic/[email protected]#egg=pyxform-medic
E OSX
E       pip install git+https://github.com/medic/[email protected]#egg=pyxform-medic
E Windows (as Administrator)
E       python -m pip install git+https://github.com/medic/[email protected]#egg=pyxform-medic --upgrade 
  1. Run sudo python -m pip install git+https://github.com/medic/[email protected]#egg=pyxform-medic
  2. User gets an error

Expected behavior Commands provided should not result in error

Logs

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.

Screenshots If applicable, add screenshots to help explain your problem.

Environment

  • Client platform: Linux Manjero
  • Python: 3.11.7
  • cht-conf version: 3.21.4

Additional context Run with --break-system-packages

kennsippell avatar Mar 07 '24 16:03 kennsippell

This is not a cht-conf error per se, since python 3.11 the packages need to be installed within a virtual environment. However, the cht-conf installation document needs an update on this. A workaround for this would be to create a virtual environment in the folder where you want to run the cht <command>. Another workaround is to create a single virtual environment anywhere in your system and export its path into the Linux PATH variable such that xls2xform-medic: (the binary that cht needs) is always available.

sugat009 avatar Sep 13 '24 10:09 sugat009