Sync Pipfile changes with virtualenv
See original GitHub issueAfter modifiying Pipfile/Pipfile.lock (i.e. after a git checkout
) I would expect that there is a simple command, that syncs the changes back to the virtual environment. Ideally it is done automaticially when running pipenv shell
/pipenv run
. At least I would expect pipenv check
to warn if Pipfile does not matcb to the environment any more.
But neither did I find a command to sync the files with environment manually nor did run/shell sync them automaticially nor did check
return errors.
What I did was:
pipenv install <packagename>==<version1>
- save Pipfile (i.e. by git commit)
pipenv install <packagename>==<version2>
- restore Pipfile (i.e. by git checkout)
- run any pipenv command => commands are done within an environment that has <version2> installed
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Advanced Usage of Pipenv - Read the Docs
This causes Pipenv to ignore changes to the Pipfile and (more importantly) prevents it from adding the current environment to Pipfile.lock . This...
Read more >Basic Usage of Pipenv - Python Packaging Authority
Pipfiles contain information for the dependencies of the project, and supersedes the requirements.txt file used in most Python projects.
Read more >pipenv Documentation - Read the Docs
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the. Python...
Read more >Pipenv & Virtual Environments
virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need. It can be...
Read more >What's wrong with pipenv? I am genuinely curious. On local
Minor python version changes and the venv is toast? Different ways of structuring ... time pipenv sync Installing dependencies from Pipfile.lock (3f6ae1)…
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One of the nice things of pipenv is, that every commit has its own virtualenv spec (in Pipfile.lock). My understanding is, that when I checkout a commit pipenv will guarantee that I work with exactly the same virtualenv I worked when I checked out this commit the last time (similarly to git, which guarantees that I work with exactly same codebase).
pipenv update
is not appropriate for this, as it does not create a virtualenv as described in ‘Pipfile.lock’, but it does exactly the opposite: it creates a ‘Pipfile.lock’ from a virtualenv (after upgrading the virtualenv to the newest packages).In the meantime I found a operation which does exactly what I want:
But this as far from intuitive.
Furthermore:
pipenv shell
orpipenv run
guarantees that you have a virtualenv when being run the first time. Why does it not ensure this on every run (=check if the virtualenv is different from Pipfile.lock and restore it if not so)?I’m not sure whether it’s clear what you’re exactly trying to do. Your “What I did” example is not very clear.
Were you trying to do this?
Although you now have your old
Pipfile
(pre-installation ofmynewpackage
in the branchnewbranch
), that package is still installed in your current environment. You want to get rid of that, right?Just use
pipenv update
. This will compare your environment against yourPipfile
, purge all packages and reinstall everything.