Select to view content in your preferred language

Distributing virtual environment to coworkers

3619
12
06-10-2022 12:33 PM
Glasnoct
Regular Contributor

Our current toolbox of scripts requires the installation of some modules that do not come with ArcPro out of the box and the current solution has been to have coworkers fire up the Python command prompt and do a "pip install" for the missing modules but that is proving to be too advanced for them and thus I'm looking for a simpler solution.

What's the easiest way I can keep everyone up to date with any dependencies we need? Can I just do a copy-paste of the virtual environment folder? Could I clone the environment to a shared directory and have them point their project environment to that? That would be useful as I can update it as necessary and it will "populate" to all the other users.

0 Kudos
12 Replies
Glasnoct
Regular Contributor

I spoke too soon it seems as this method doesn't totally work. If I try to run it twice in a row (to check that it find all the installed modules on the second run) it still installs them again. If I run the code and then at the end just attempt to import the installed modules it throws an error about being unable to find first one it comes across. No idea if that's an issue with trying to install modules without, like, restarting Arc or what.  

Also had an issue with getting some of the dependencies installed for the modules. Pywin32 seems to need admin rights to install, which is a nonstarter if the script is being run by the end user as they won't be running it with admin rights. pip with '--user' is said to work but I don't know if it IS or not to be honest.

0 Kudos
by Anonymous User
Not applicable

That is a bummer!  If you want to revisit the bat file, here it is in a complete version.  The user/ admin thing is probably due to trying to write to C:/Program Files... with all the cloned environments that there might be, its hard to say where the packages are trying to get installed.  That is one reason I went for creating an environment and setting it for my stuff, and for getting the packages that the user may have installed from their clone.  Wish there was an easier way for this....

 

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: VARIABLES :
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off

SETLOCAL

SET "ENV_NAME=assessors-env"

SET "PRO_PATH=C:\Program Files\ArcGIS\Pro\bin\Python"
SET "REQ_PATH=\\path to the requirements.txt"
SET PATH=%PATH%;"C:\Program Files\ArcGIS\Pro\bin\Python\Scripts"
SET PATH=%PATH%;"%PRO_PATH%\envs\%ENV_NAME%\Scripts"


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: COMMANDS :
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

REM start by activating the arcgis pro conda env
call "C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\activate.bat" & (

REM update the new environment with pip packages.
pip install -r "%REQ_PATH%\requirements.txt"
ECHO ^-^-^> %ENV_NAME% environment updated pip
)

exit

0 Kudos
by Anonymous User
Not applicable

I created an ArcGIS Idea for to cover stuff like this.  I'd appreciate any thumbs up/ comments/ support for it so we can get some solid guidance.

create documentation for esri's conda 

0 Kudos