question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pipenv sync should uninstall packages that have been removed from lockfile

See original GitHub issue

Issue description

My mental model for pipenv sync is “make the state of the virtualenv be exactly like what’s described in Pipfile.lock”. Thus, I would expect pipenv sync to uninstall any packages that are installed in the virtualenv, but not mentioned in the lockfile. Currently however, those packages simply are left as-is.

Steps to replicate

$ pipenv install requests
$ pipenv run python -c 'import requests'  # this works, of course :)
$ sed -i -e '/^requests =/d' Pipfile
$ pipenv lock
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (16c839)!
$ pipenv sync
Installing dependencies from Pipfile.lock (fe5a22)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!
$ pipenv run python -c 'import requests'  # expected result: ModuleNotFoundError, actual result: it still works
$ pipenv --support

Pipenv version: '2020.11.15' Pipenv location: '/Users/schnerring/install/tools/lib/python3.9/site-packages/pipenv' Python location: '/Users/schnerring/install/tools/bin/python3'

Python installations found:

  • 3.9.1: /usr/local/bin/python3
  • 3.9.1: /usr/local/bin/python3.9
  • 3.8.7: /usr/local/bin/python3.8
  • 3.7.9: /usr/local/bin/python3.7
  • 2.7.16: /usr/bin/python2.7

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.9.1',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '18.7.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 18.7.0: Tue Jan 12 22:04:47 PST '
                     '2021; root:xnu-4903.278.56~1/RELEASE_X86_64',
 'python_full_version': '3.9.1',
 'python_version': '3.9',
 'sys_platform': 'darwin'}

System environment variables:

  • ANDROID_SDK_ROOT
  • Apple_PubSub_Socket_Render
  • COLORFGBG
  • COLORTERM
  • COMMAND_MODE
  • EDITOR
  • HOME
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_TERMINAL
  • LC_TERMINAL_VERSION
  • LESS_TERMCAP_md
  • LESS_TERMCAP_me
  • LESS_TERMCAP_se
  • LESS_TERMCAP_ue
  • LESS_TERMCAP_us
  • LOGNAME
  • PATH
  • PIPENV_IGNORE_VIRTUALENVS
  • PWD
  • PYTHONSTARTUP
  • SECURITYSESSIONID
  • SHELL
  • SHLVL
  • SSH_AUTH_SOCK
  • TERM
  • TERM_PROGRAM
  • TERM_PROGRAM_VERSION
  • TERM_SESSION_ID
  • TMPDIR
  • USER
  • XPC_FLAGS
  • XPC_SERVICE_NAME
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

  • PIPENV_IGNORE_VIRTUALENVS: 1

Debug–specific environment variables:

  • PATH: /Users/schnerring/bin:/usr/local/bin:/Users/schnerring/.krew/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • SHELL: /bin/bash
  • EDITOR: emacs-minimal
  • LANG: en_GB.UTF-8
  • PWD: /Users/schnerring

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Mausecommented, Feb 17, 2021

Is your pipenv reset just pipenv clean?

Uninstalls all packages not specified in Pipfile.lock.

And your pipenv update just pipenv lock?

Generates Pipfile.lock.

0reactions
wosccommented, Feb 19, 2021

Oh. Yes. Execellent. Sorry that I didn’t look at the docs carefully enough to spot this. Thanks for letting me know!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to remove a dependency from the Pipfile.lock file ...
I can say pipenv uninstall dependency , but that will uninstall it from the venv not the Pipfile.lock file. If anyone knows how...
Read more >
Release and Version History — pipenv 2020.6.2.dev0 ...
pipenv install and pipenv sync will no longer attempt to install satisfied ... that would otherwise be dropped from any entries that have...
Read more >
Common Pipenv Errors and How to Solve Them: Why Won't it ...
Locking Issue: Pipfile Contains a Reference to an Inexistent Package ... Pipfile won't lock when it tries to install packages that don't exist,...
Read more >
pipenv Documentation - Read the Docs
--all-dev — This parameter will remove all of the development packages from the virtual environment, and remove them from the Pipfile. $ pipenv...
Read more >
Configure a Pipenv environment | PyCharm Documentation
It automatically manages project packages through the Pipfile file as you install or uninstall packages. Pipenv also generates the Pipfile.lock file, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found