Questions about setting up virtual environment

13 views
Skip to first unread message

Moroney, Catherine M (US 398E)

unread,
Oct 11, 2022, 5:29:35 PM10/11/22
to Anaconda - Public

Hello,

 

I am about to start converting a large chunk of code from Python2 to Python3 and have some questions as to how to proceed.  Ideally I would like to set up both versions of code in different virtual environments and then just switch back and forth between the two environments when debugging and testing.

 

I’ve used conda a bit in the past, added and installed python packages to an environment and then successfully used them to run my code.  But I have a slightly different use-case this time in that the code that needs to be converted isn’t a “package”, but rather a collection of 40+ stand-alone scripts.  So, what would be the easiest way to have the versatility of virtual environments and quickly/seamlessly switch from running the Python2 version of the scripts to the Python3 version?

 

I can think of a few “hack-jobs” (i.e. setting PYTHONPATH to the conda package directory for the environment that I want to run in), but I hope there’s a more proper/seamless way to accomplish this.

 

Thank you for any advice,

 

Catherine

 

 

Brian Toby

unread,
Oct 11, 2022, 6:23:14 PM10/11/22
to Anaconda - Public, Catherine...@jpl.nasa.gov
Hi Catherine,

   This is exactly what conda is for. One uses conda create to with the specific python and package versions you want and  then you can switch between the two environments using the activate command. Having said this, I often install conda in multiple locations so that I can delete versions that I don't need by just deleting the entire directory tree.

Brian

Moroney, Catherine M (US 398E)

unread,
Oct 11, 2022, 8:16:35 PM10/11/22
to Brian Toby, Anaconda - Public

My question is how to use conda to create a virtual environment for something that really isn’t a proper python “package”, but rather a collection of 40+ separate executable scripts.

What’s the best, least-kludgy way of getting all these scripts into conda so I can switch between the python2 and python3 versions of them seamlessly? 

 

Catherine

Reply all
Reply to author
Forward
0 new messages