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

Ability to reinstall a different version of a package #51

Open
rth opened this issue Jan 26, 2023 · 2 comments · May be fixed by #64
Open

Ability to reinstall a different version of a package #51

rth opened this issue Jan 26, 2023 · 2 comments · May be fixed by #64
Labels

Comments

@rth
Copy link
Member

rth commented Jan 26, 2023

Currently if a package is already installed, we can't re-install a different version,

>>> import micropip
>>> await micropip.install('packaging==23.0')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/lib/python3.10/site-packages/micropip/_micropip.py", line 573, in install
    await transaction.gather_requirements(requirements)
  File "/lib/python3.10/site-packages/micropip/_micropip.py", line 333, in gather_requirements
    await gather(*requirement_promises)
  File "/lib/python3.10/asyncio/futures.py", line 284, in __await__
    yield self  # This tells Task to wait for completion.
  File "/lib/python3.10/asyncio/tasks.py", line 304, in __wakeup
    future.result()
  File "/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/lib/python3.10/asyncio/tasks.py", line 232, in __step
    result = coro.send(None)
  File "/lib/python3.10/site-packages/micropip/_micropip.py", line 340, in add_requirement
    return await self.add_requirement_inner(Requirement(req))
  File "/lib/python3.10/site-packages/micropip/_micropip.py", line 418, in add_requirement_inner
    if self.check_version_satisfied(req):
  File "/lib/python3.10/site-packages/micropip/_micropip.py", line 364, in check_version_satisfied
    raise ValueError(
ValueError: Requested 'packaging==23.0', but packaging==21.3 is already installed

On one side it's probably not ideal to do that, particularly given that micropip itself depends on packaging in this case. Still it feels like an arbitrary limitation. IMO in this case it would be better to uninstall the previous package version and install the new version.

@ryanking13
Copy link
Member

Yeah, sometimes we want to install a newer or old version during runtime, so I'm +1 for having the option to reinstall. A possible issue is that how we should deal with a package that is already imported.

@rth
Copy link
Member Author

rth commented Jan 26, 2023

A possible issue is that how we should deal with a package that is already imported.

It's the same problem as pip installing things in a running Jupyter notebook. IMO users would still need to explicitly either calling importlib.reload or using an auto-reload plugin like in Jupyter.

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

Successfully merging a pull request may close this issue.

2 participants