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.

Old dependency from install_requires not removed from env after removal from manifest

See original GitHub issue

After removing a dependency from install_requires in my setup.py, and running pipenv update, the removed dependency is still present in the environment.


Please run $ python -m pipenv.help, and paste the results here.

Pipenv version: '11.8.0'

Pipenv location: '/usr/local/Cellar/pipenv/11.8.0/libexec/lib/python3.6/site-packages/pipenv'

Python location: '/usr/local/Cellar/pipenv/11.8.0/libexec/bin/python'

Other Python installations in PATH:

  • 2.7: /usr/local/bin/python2.7

  • 2.7: /usr/local/bin/python2.7

  • 2.7: /usr/bin/python2.7

  • 3.6: /usr/local/bin/python3.6m

  • 3.6: /usr/local/bin/python3.6

  • 2.7.14: /usr/local/bin/python

  • 2.7.10: /usr/bin/python

  • 2.7.14: /usr/local/bin/python2

  • 3.6.4: /usr/local/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.4',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '17.4.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST '
                     '2017; root:xnu-4570.41.2~1/RELEASE_X86_64',
 'python_full_version': '3.6.4',
 'python_version': '3.6',
 'sys_platform': 'darwin'}

Expected result

I would expect that the dependency is removed from the environment, as nothing depends on it anymore.

Actual result

See detailed steps to replicate below:

Steps to replicate

Create the following simple setup.py

from setuptools import setup

setup(
    name='pipenvtest',
    version='0.1.0',
    description='testing',
    license='MIT',
    install_requires=[
        'plain_obj ~= 0.1.2',
    ]
)

Create a new pipenv by installing the current directory as editable pipenv install -e .

Check the dependency graph for the env, all looks good:

> pipenv graph
pipenvtest==0.1.0
  - plain-obj [required: ~=0.1.2, installed: 0.1.2]

Update setup.py to comment out the one dependency - this simulates removing a dependency

    install_requires=[
        # 'plain_obj ~= 0.1.2',
    ]

Run pipenv update to update the lockfile and environment

> pipenv update
Running $ pipenv lock then $ pipenv sync.
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (86895b)!
Installing dependencies from Pipfile.lock (86895b)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:00
To activate this project's virtualenv, run the following:
 $ pipenv shell
All dependencies are now up-to-date!

Run pipenv graph to view the environment

> pipenv graph
pipenvtest==0.1.0
plain-obj==0.1.2

plain-obj is still there - although it is no longer present in the lockfile.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
glenjamincommented, Apr 2, 2018

Ok, that mostly makes sense.

The word sync implies to me that it would synchronise my environment against my lockfile - although to be fair the help text "Installs all packages specified in Pipfile.lock." doesn’t say this. The current semantics appear to be more of an ensure. (I’m not suggesting it be renamed).

You say that nothing pipenv does is secretly destructive - but does that mean sync will also refuse to downgrade a dependency that was previously installed if the lockfile has changed?

It would be useful to future users if the documentation contained an overview of the commands and the scenarios they’re expected to be used.

The same behaviour is seen if a dependency is removed from the Pipfile and lock + sync are run. I think it is non-obvious that the environment isn’t fully synchronised until also running the clean command.

1reaction
glenjamincommented, Apr 2, 2018

I’ve just spotted the pipenv clean command - not sure how I overlooked this before.

Is there anywhere I can read up on why clean is a distinct separate step rather than part of sync?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reference requirements.txt for the install_requires kwarg in ...
txt , the simple answer astutely noted by Tobu below is to list all dependencies in setup.py and remove requirements.txt . For applications...
Read more >
#30913 (sagelib: Generate pyproject.toml and setup.cfg ...
As part of bootstrap , we now generate (1) the pyproject.toml (PEP 517 metadata) and install_requires information, (2) requirements.txt and (3) Pipfile using...
Read more >
pipenv Documentation - Read the Docs
This shell can be deactivated by using exit. run will run a given command from the virtualenv, with any arguments forwarded (e.g. $...
Read more >
How to Package Python dependencies with PIP setuptools
install_requires is a section within the setup.py file in which you need to input a list of the minimum dependencies needed for a...
Read more >
Paver Changelog — Paver 1.3.4 documentation
Minilib is now imported only if full paver is not available (github ... correctly handle dependencies in install_requires directive for ...
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