Ability to reinstall a different version of a package
Opened this issue · 2 comments
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.
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.
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.