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

Installing Additional Packages at runtime #67

Open
psychemedia opened this issue Nov 8, 2022 · 16 comments
Open

Installing Additional Packages at runtime #67

psychemedia opened this issue Nov 8, 2022 · 16 comments
Labels
enhancement New feature or request

Comments

@psychemedia
Copy link

Is there any way for a user to installing additional packages from pip into a running xeus-python kernel?

@psychemedia psychemedia added the documentation Improvements or additions to documentation label Nov 8, 2022
@martinRenou
Copy link
Member

It's not available (yet?). I guess it could be done for pure Python packages, but for now you'll need to rely on conda-forge and emscripten-forge packages.

@DerThorsten
Copy link
Collaborator

It's not yet working but we working on integrating micropip and a very slim mamba (picomamba) into xeus-python.

@martinRenou
Copy link
Member

I guess the original question was concerning pre-installed packages?

@DerThorsten
Copy link
Collaborator

Is there any way for a user to installing additional packages from pip into a running xeus-python kernel?

but his question is about installing in a "running" kernel, ie not pre-install?

@psychemedia
Copy link
Author

Original comment was more along the lines of: I am in a notebook running a xeus-python kernel; how do I do an equivalent of %pip install newPackage.

@psychemedia
Copy link
Author

Elsewhere, I learned that the default pyodide kernel now supports %pip magic.

@jtpio
Copy link
Member

jtpio commented Dec 14, 2022

Elsewhere, I learned that the default pyodide kernel now supports %pip magic.

Yes this was added in 0.1.0b14: https://jupyterlite.readthedocs.io/en/latest/changelog.html#b14

@martinRenou martinRenou changed the title Installing Additional Packages Installing Additional Packages at runtime Jan 2, 2023
@martinRenou martinRenou added enhancement New feature or request and removed documentation Improvements or additions to documentation labels Jan 2, 2023
@jtpio
Copy link
Member

jtpio commented Mar 24, 2023

For reference micropip should now be available on conda-forge: https://github.com/conda-forge/micropip-feedstock

It would be interesting to get it to install packages on the fly in the xeus python kernel.

@jtpio
Copy link
Member

jtpio commented Mar 31, 2023

It would be interesting to get it to install packages on the fly in the xeus python kernel.

Gave this a try with the following environment.yml:

name: test
channels:
- https://repo.mamba.pm/emscripten-forge
- https://repo.mamba.pm/conda-forge
dependencies:
- micropip

Importing micropip works:

import micropip
micropip.__version__
# '0.3.0'

Installing a package with:

micropip.install('emoji')

Then importing it with:

import emoji

Gives the following:

image

@psychemedia
Copy link
Author

psychemedia commented Oct 4, 2023

Any updates on the ability to install packages at runtime?

(To a certain extent, NOT supporting this might be useful in an educational context, if you want students to be limited to using just and only what is provided...)

Having micropip available might be handy when working out what's required when putting toigether a new environment, though...

@jtpio
Copy link
Member

jtpio commented Oct 4, 2023

(To a certain extent, NOT supporting this might be useful in an educational context, if you want students to be limited to using just and only what is provided...)

Probably this would be the case depending on whether the micropip (or equivalent) package is available in the kernel environment, which would be controlled by the site deployer.

@martinRenou
Copy link
Member

martinRenou commented Oct 4, 2023

The coming update to the new emscripten-wasm32 platform may allow using micropip? @DerThorsten

@psychemedia
Copy link
Author

psychemedia commented Oct 4, 2023

Thinking about the environment.yaml config file, the "normal" config file spec allows you to install pip as a dependency and then provide a sublist of pip packages to install from PyPI. Is there any sense in which you can installpip or micropip packages as part of the xeus-python-kernel's environment.yaml file?

@martinRenou
Copy link
Member

As of recently xeus-python allows partial support for installing pip dependencies: https://xeus-python-kernel.readthedocs.io/en/latest/configuration.html#pip-packages

Though you should not specify pip in the dependency list. We should probably take care of this case though. I'll open an issue for that.

@jtpio jtpio transferred this issue from jupyterlite/xeus-python-kernel Feb 14, 2024
@pierre-haessig
Copy link

Hello, I'm wondering if the support for installing pure Python package with pip (https://xeus-python-kernel.readthedocs.io/en/latest/configuration.html#pip-packages) is still considered experimental.

In the meantime, I see that jupyterlite-xeus-python is being deprecated over jupyterlite-xeus (https://xeus-python-kernel.readthedocs.io/en/latest/migration.html#migration), but I see the corresponding doc at https://jupyterlite-xeus.readthedocs.io/en/latest/environment.html#pip-packages with about the same content.

@martinRenou
Copy link
Member

It is indeed still experimental.

The biggest downside of it is that it installs your package with the --no-deps option passed to pip so you'll have to install the dependencies yourself, either from Pypi or conda-forge or emscripten-forge.

Maybe one day we'll have a better approach for this.

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

No branches or pull requests

5 participants