Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive installation of cython via the pip package manager inside the alpine container in the "Creating Your Own Container Images" does not work anymore #209

Open
krishnakumarg1984 opened this issue May 13, 2024 · 4 comments

Comments

@krishnakumarg1984
Copy link
Contributor

krishnakumarg1984 commented May 13, 2024

)In the lesson on Creating Your Own Container Images, in the interactive installation section, we currently have the command to install cython within the container as

$ pip install cython

As of May 2023, pip version 23.3.1 (which gets installed by the previous command in the lesson $ apt add --update python3 py3-pip python3-dev, this does not work anymore!

When we run the above command, we get the following error:

error: externally-managed-environment

× This environment is externally managed
╰─>
    The system-wide python installation should be maintained using the system
    package manager (apk) only.

    If the package in question is not packaged already (and hence installable via
    "apk add py3-somepackage"), please consider installing it inside a virtual
    environment, e.g.:

    python3 -m venv /path/to/venv
    . /path/to/venv/bin/activate
    pip install mypackage

    To exit the virtual environment, run:

    deactivate

    The virtual environment is not deleted, and can be re-entered by re-sourcing
    the activate file.

    To automatically manage virtual environments, consider using pipx (from the
    pipx package).

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.

Cython does not get installed. I am not quite sure if it is acceptable to teach/encourage students to pass the --break-system-packages flag to pip just to get around this issue (we'll have to update the lessons in multiple places as well as the two Dockerfiles located within the docker-intro.zip file). Even when passing this flag, after the installation of cython, we get a strong warning:

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. 
It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Perhaps a different example (maybe a non-python one) shall be helpful to avoid such confusions (esp to beginners)?

@aturner-epcc
Copy link
Contributor

Thanks for spotting this and raising the issue. We need to have a think about what the example should be - Python was chosen for a reason as it is something that users often want to install but if it no longer works in a sensible way then a rethink is needed.

Potential options:

  • Installing R (maybe too large to be a useful example)
  • Creating a venv as part of the install process as suggested in the output above
  • Picking a completely different tool (happy to hear any suggestions)

@aturner-epcc
Copy link
Contributor

OK - recent PRs have removed the Cython install via pip to get rid of the rror in the short term. We should review if this is the correct approach long term

@krishnakumarg1984
Copy link
Contributor Author

krishnakumarg1984 commented May 14, 2024

@aturner-epcc

We need to have a think about what the example should be

How about invoking gcc --version as the default entrypoint command? We could have the task of compiling & running a simple hello_world.c file in lieu of the python example? Alpine being so minimal, probably doesn't have gcc in its default image, and we get to demonstrate the apk add gcc command for both the interactive and the dockerfile sections of the lesson. Will also require rewriting sum.py in C. Thoughts?

@aturner-epcc
Copy link
Contributor

Possibly. Most course attendees do not use compilers on a day-to-day basis so this may not be a good choice as you will likely need to explain what a compiler is for attendees which is a rabbit hole we probably do not want to go down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants