Python Forum
Managing dependencies with pipenv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Managing dependencies with pipenv
#1
So I had a project I was working on in a pipenv virtual environment. My computer took a crap and I had to re-install my OS. Luckily I had a copy of the .virtualenv folder backed up. I tried to copy this folder back into my fresh install, and run a pipenv shell in the dir, but was given a brand new virutal environment, with no dependencies installed.

Is there any way to migrate that original virtual environment to the new pc? Dependencies and all? I thought that was the point of using a virtual environment?

If not, I would like to know how to get this back up and running. When I do pipenv install it fails to get a lock. When I do pipenv install --skip-lock I'm still getting general failures to find a place to install the dependencies. Everything just seems super out of sync.

When I look in my pip file, I didn't specify version numbers for dependencies, and I feel this might have something to do with my issues. I just have entries like
json-decode = "*"
datetime = "*"
configparser = "*"
pyodbc = "*"
.

Anybody have some advice on how I can get my program up and running again?
Thank you
Reply
#2
The following for Linux will need some modification for other OS
There's most likely a better way, but this will work: You can
  • on the new system, check pyenv python versions installed with pyenv versions
  • If necessary, install the python version that your old environment used with pyenv install 3.7.0 (using required version)
  • Once installed set global pyenv version with pyenv global 3.7.0
  • Create new shell environment (in project directory) with python -m venv yourvenvname don't delete old venv
  • Activate NEW venv environment (important step)
  • Create a shell requirements.txt file with pip freeze > requirements.txt
  • deactivate new venv
  • Set global pyenv python version to one required as your standard 3.8.3 or whatever again: pyenv global 3.8.3
  • look at the venv/lib/python3.8/site-packages on the old virtual environment (change venv (to your virtual environment name) and python version as required) add the needed packages to the requirements.txt file just created.
  • reactivate new virtual environment: . ./venv/bin/activate
  • upgrade pip: pip install --upgrade pip
  • add packages: pip install -r requirements.txt
  • You should now be back in business.
  • check python version python -V should show old version
Reply
#3
(Jul-29-2020, 12:44 AM)t4keheart Wrote: Is there any way to migrate that original virtual environment to the new pc?
Move the folder over to new Pc there should be Pipfile and Pipfile.lock in that folder.
The on command line inside that folder do pipenv install.
Then activate shell pipenv shell then can do pipenv graph and all dependencies shoud be there.
Example.
Now have just moved the folder new_env folder to another location.
C:\config\new_env
λ pipenv install
Creating a virtualenv for this project…
Pipfile: C:\config\new_env\Pipfile
Using C:/Python38/python.exe (3.8.3) to create virtualenv…
[====] Creating virtual environment...created virtual environment CPython3.8.3.final.0-32 in 1022ms
  creator CPython3Windows(dest=C:\Users\Tom\.virtualenvs\new_env-Zym8GkqR, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\Tom\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.1.1, setuptools==49.2.0, wheel==0.34.2
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

Successfully created virtual environment!
Virtualenv location: C:\Users\Tom\.virtualenvs\new_env-Zym8GkqR
Installing dependencies from Pipfile.lock (b1b681)…
  ================================ 11/11 - 00:00:11
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
So if activate shell and do pipenv graph.
The dependencies will be there.
C:\config\new_env
λ pipenv shell
Launching subshell in virtual environment…

C:\config\new_env
(new_env-Zym8GkqR) λ pipenv graph
Flask==1.1.2
  - click [required: >=5.1, installed: 7.1.2]
  - itsdangerous [required: >=0.24, installed: 1.1.0]
  - Jinja2 [required: >=2.10.1, installed: 2.11.2]
    - MarkupSafe [required: >=0.23, installed: 1.1.1]
  - Werkzeug [required: >=0.15, installed: 1.0.1]
requests==2.24.0
  - certifi [required: >=2017.4.17, installed: 2020.6.20]
  - chardet [required: >=3.0.2,<4, installed: 3.0.4]
  - idna [required: >=2.5,<3, installed: 2.10]
  - urllib3 [required: >=1.21.1,<1.26,!=1.25.1,!=1.25.0, installed: 1.25.10]
'
Reply
#4
(Jul-29-2020, 12:44 AM)Larz60+ Wrote: The following for Linux will need some modification for other OS
There's most likely a better way, but this will work: You can
  • on the new system, check pyenv python versions installed with pyenv versions
  • If necessary, install the python version that your old environment used with pyenv install 3.7.0 (using required version)
  • Once installed set global pyenv version with pyenv global 3.7.0
  • Create new shell environment (in project directory) with python -m venv yourvenvname don't delete old venv
  • Activate NEW venv environment (important step)
  • Create a shell requirements.txt file with pip freeze > requirements.txt
  • deactivate new venv
  • Set global pyenv python version to one required as your standard 3.8.3 or whatever again: pyenv global 3.8.3
  • look at the venv/lib/python3.8/site-packages on the old virtual environment (change venv (to your virtual environment name) and python version as required) add the needed packages to the requirements.txt file just created.
  • reactivate new virtual environment: . ./venv/bin/activate
  • upgrade pip: pip install --upgrade pip
  • add packages: pip install -r requirements.txt
  • You should now be back in business.
  • check python version python -V should show old version
(Jul-29-2020, 12:44 AM)Larz60+ Wrote: The following for Linux will need some modification for other OS
There's most likely a better way, but this will work: You can
  • on the new system, check pyenv python versions installed with pyenv versions
  • If necessary, install the python version that your old environment used with pyenv install 3.7.0 (using required version)
  • Once installed set global pyenv version with pyenv global 3.7.0
  • Create new shell environment (in project directory) with python -m venv yourvenvname don't delete old venv
  • Activate NEW venv environment (important step)
  • Create a shell requirements.txt file with pip freeze > requirements.txt
  • deactivate new venv
  • Set global pyenv python version to one required as your standard 3.8.3 or whatever again: pyenv global 3.8.3
  • look at the venv/lib/python3.8/site-packages on the old virtual environment (change venv (to your virtual environment name) and python version as required) add the needed packages to the requirements.txt file just created.
  • reactivate new virtual environment: . ./venv/bin/activate
  • upgrade pip: pip install --upgrade pip
  • add packages: pip install -r requirements.txt
  • You should now be back in business.
  • check python version python -V should show old version
Reply
#5
why is everyone repeating what I wrote, and (snippsat) what I didn't?
Reply
#6
(Jul-29-2020, 03:20 PM)Larz60+ Wrote: why is everyone repeating what I wrote, and (snippsat) what I didn't?
Sometime it happens that it Quote wrong not sure why,fixed it now.
Reply
#7
thank you everyone for your suggestions!

I forgot to mention that for some reason my dependencies are all screwed up in that i can never get a lock on the pipfile. Even when I try --skip-lock it still fails to update dependecies.

I think I will create a new pipenv environment, then use the pipenv graph to find the dependency versions and manually install each one.

Thanks again everyone.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Pipenv mohammadasadi4 0 278 Jan-15-2024, 10:35 AM
Last Post: mohammadasadi4
  pipenv, is it still useful? LandonJPGinn 3 840 Jun-05-2023, 11:40 AM
Last Post: snippsat
  Is it possible to see dependencies before installing a package? quazirfan 4 1,052 Dec-06-2022, 02:50 PM
Last Post: snippsat
  managing new windows JonWayn 1 1,756 Sep-22-2022, 05:26 PM
Last Post: Larz60+
  Libraries installed with pipenv, but ModuleNotFoundError returned jpncsu 2 2,982 Sep-06-2021, 07:24 PM
Last Post: jpncsu
  Managing Objects JoeDainton123 1 1,684 May-15-2021, 03:18 PM
Last Post: Yoriz
  setting up pipenv tobiasfw 1 2,001 Jan-13-2021, 05:46 PM
Last Post: buran
  Easier way to manage dependencies? Tylersuard 2 2,350 Jan-01-2020, 09:19 PM
Last Post: Tylersuard
  managing command codes for external controller box Oolongtea 0 1,908 Sep-19-2019, 08:32 AM
Last Post: Oolongtea
  Missing required dependencies when using pyinstaller Ghonim 15 23,275 Jul-15-2019, 08:47 AM
Last Post: shubhthkr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020