How I manage environments

68 views
Skip to first unread message

Edward K. Ream

unread,
Apr 13, 2021, 10:57:59 AM4/13/21
to leo-editor
Here is how I switch between different versions of python. It could be extended to handle different versions of qt, but I haven't done that.

The advantages of my scheme are:

- It uses no extra software, just python and pip.
- It does not change the state of the system in any way.
- It makes no changes to system settings.
- It does not use sitecustomize.py.
- It allows me to install all my Leo-related software in my home directory.

For each version V (say 3.9), of python, I do the following:

- Install python 3.9 in my home directory, choosing "no" when asked if I want to change the system's path var.
- Create aliases (.bat files) for leo39 and pip39.
- Create aliases (.bat files) that open various .leo files using python 3.9. These aliases all call leo39.

Python 3.9 is the default, I also create aliases that don't have a version number.  But not plain "pip": I want to have to specify the version number explicitly when I install packages.

That's all.

Summary

I use aliases (.bat files) to specify the desired environment. aliases without a version suffix denote the default environment.

This scheme works well for me. You might like it as well.

Edward

tbp1...@gmail.com

unread,
Apr 13, 2021, 12:11:53 PM4/13/21
to leo-editor
I also use a batch file to launch Python 3.8.  In my case, I also have Python 2.7 on the machine, and paths for 2.7 are in the path.  So my batch file also mangles those 2.7 paths so they don't interfere with the 3.8 ones.  (I still need 2.7 for work on one particular project).

I'm considering creating a batch file to set the PYTHONPATH to use my git clone for development, and another to set up for pyqt6.  But I'm not convinced that these things are worth the trouble to keep the extra batch files straight in my memory.

Like you, I always make sure I'm using the right version of pip.  But I don't do it by specifying the version (e.g., pip3).  Instead, I launch it using

pyxx -m pip

This automatically makes sure that the correct version of pip gets used, whichever version of Python I'm using.

tbp1...@gmail.com

unread,
Apr 13, 2021, 3:22:43 PM4/13/21
to leo-editor
How are you launching python to use or not to use pyqt6?  Do you actually have separate Python installations?

Edward K. Ream

unread,
Apr 13, 2021, 4:23:00 PM4/13/21
to leo-editor
On Tue, Apr 13, 2021 at 2:22 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
How are you launching python to use or not to use pyqt6?  Do you actually have separate Python installations?

Yes. As far Windows 10 is concerned, there is no python installation. I have four python folders, each contained in ~/Python: Python36, ..., Python39.

Python39 is the default, so the following .bat files all use Python 39:

- leo.bat: Launches Leo with arguments as specified by %*.
- e.bat: launches my private test file, ekr.leo.
- d.bat: launches LeoDocs.leo.
- s.bat: launches leoPy.leo

For each installation, there are specific batch files, e36.bat, d36.bat, etc.

Again, plain 'pip' does not work, on purpose.  And the "specific" pips, pip39 etc all complain that python is not in the path, which again is on purpose.

Edward

TEK42

unread,
Apr 14, 2021, 9:51:51 AM4/14/21
to leo-editor
Thanks for this info - gives me clearer ideas on how to implement similar pattern in OS X. I’ve had some difficulty so far with trying to integrate with the os via Automator scripts, etc; simple shell scripts may be the best way to proceed.
Reply all
Reply to author
Forward
0 new messages