When I run pipenv uninstall, I am counting on uninstalling the package with all it's dependencies that are not shared with other packages.
Maybe having this behaviour by default is too aggressive, but having at least a flag would be awesome.
$ python -V
Python 3.6.4$ pipenv --version
pipenv, version 9.0.3I would expect pipenv to uninstall all dependencies of distex (dill, cloudpickle).
(mos-bot-NUxJbKoW) javier@sam> pipenv install distex
Installing distex…
Collecting distex
Downloading distex-0.5.6-py3-none-any.whl
Collecting dill (from distex)
Downloading dill-0.2.7.1.tar.gz (64kB)
Collecting cloudpickle (from distex)
Downloading cloudpickle-0.5.2-py2.py3-none-any.whl
Building wheels for collected packages: dill
Running setup.py bdist_wheel for dill: started
Running setup.py bdist_wheel for dill: finished with status 'done'
Stored in directory: /.../.cache/pip/wheels/e5/88/fe/7e290ce5bb39d531eb9bee5cf254ba1c3e3c7ba3339ce67bee
Successfully built dill
Installing collected packages: dill, cloudpickle, distex
Successfully installed cloudpickle-0.5.2 dill-0.2.7.1 distex-0.5.6
Adding distex to Pipfile's [packages]…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (8bce4b)!
(mos-bot-NUxJbKoW) javier@sam > pipenv uninstall distex
Un-installing distex…
Uninstalling distex-0.5.6:
Successfully uninstalled distex-0.5.6
Removing distex from Pipfile…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (154010)!
pipenv install distex
pipenv uninstall distex
Here all 3 packages should be deleted
Pipenv uses pip underneath to install/uninstall packages, and is therefore not able to do well here because pip does not have a dependency resolver, and has no way to know whether a dependency is no longer needed. Pipenv, therefore, cannot do this at the moment.
It is technically possible to implement a pipenv clean
command, that functions similar to apt autoremove
. The command would compare the current environment to the lock file, and remove all packages not in it. I’m not sure if anyone is interested in implementing this, or if it would be accepted (although I’m personally +1 to this).
Yep, I understood that if there is something like pipenv graph
, we could probably make a difference with the output of pip freeze =)
@uranusjr I would be interested to do this!
@youreccentricity The best way forward would be to propose a PEEP outlining the intention, and the plan to implement it.
pipenv --rm
pipenv install
This process will work but very slow as it delete the full virtual environment and reinstall all the main dependencies.
Has anything changed since this issue was first posted? Is there any reason not to use the following:
(testpipenv) $ pipenv uninstall requests && pipenv clean
... will remove all the dependent packages and is the closest equivalent to pip-autoremove.
This may be more aggressive than intended as the clean command 'Uninstalls all packages not specified in Pipfile.lock' - If packages have not been added to Pipfile.lock before using clean, this command might remove more than intended. I do not know if this is really a concern, as uninstall automatically updates Pipfile.lock unless additional options such as --skip-lock are specified.
Most helpful comment
Pipenv uses pip underneath to install/uninstall packages, and is therefore not able to do well here because pip does not have a dependency resolver, and has no way to know whether a dependency is no longer needed. Pipenv, therefore, cannot do this at the moment.
It is technically possible to implement a
pipenv clean
command, that functions similar toapt autoremove
. The command would compare the current environment to the lock file, and remove all packages not in it. I’m not sure if anyone is interested in implementing this, or if it would be accepted (although I’m personally +1 to this).