Issues with the Python Plugin – not calling the system-wide standard Python

Inserting a python session under macOS 10.15.7 using the python plugin that ships with TeXmacs 2.1 calls

    Python 3.8.2 [/Applications/Xcode.app/Contents/Developer/usr/bin/python3] 
    Python plugin for TeXmacs.
    Please see the documentation in Help -> Plugins -> Python

i.e. the python that comes with Xcode v.12.4.

However, my system-wide standard Python is Python 3.7.10 (as set up by MacPorts) and the plugin should launch (as is does on my macOS 10.13.6 computer)

    Python 3.7.10 [/opt/local/bin/python3] 
    Python plugin for TeXmacs.
    Please see the documentation in Help -> Plugins -> Python

So my questions are:

  1. Why doesn’t the plugin call Python 3.7.10 on OSX 15.7, even though it’s definitely in the path?

  2. How can I prevent the plugin from calling Python 3.8.x without having to uninstall Xcode and its CommandLineTools?

The plugin should just be calling ‘python3’:

Can you try doing ‘which python3’ both in a terminal and in a shell session inside Texmacs?

You can also select the binary called by the instructions in the reader file.

Dear jeroen,

thanks for your fast reply. Running which python3 in a terminal, as expected, yields

    /opt/local/bin/python3

which is a symbolic link to

    /opt/local/bin/python3.7

as set up by MacPorts. Running which python3 in a shell session within TeXmacs outputs

     /usr/bin/python3

which is

    Python 3.8.2 (default, Dec 21 2020, 15:06:04) 
    [Clang 12.0.0 (clang-1200.0.32.29)] on darwin

And I have no idea

  • why the two “shells” call a different version of python3

  • how Python 3.8.2 got into /usr/bin/ in the first place, as python3 in /opt/local/bin/ is Python 3.8.10 (default, May 8 2021, 11:04:00)

  • and whether /usr/bin/python3 is redundant and can be safely removed without harming the operating system.

Having modified the python launcher in

$TEXMACS_HOME_PATH/plugins/python/progs/init-python.scm

as you suggested by adding

   (define (python-command) "/opt/local/bin/python3")

the Python session now finally calls

   Python 3.7.10 [/opt/local/bin/python3] 
   Python plugin for TeXmacs.
   Please see the documentation in Help -> Plugins -> Python

However, running which python3 in a shell session within TeXmacs still outputs

     /usr/bin/python3

Cheers
Tilda

Glad to see the workaround helped you out. It seems the terminal and TeXmacs get a different path set up. Unfortunately, I don’t know much about Mac OS. Maybe @mgubi knows.

Could you do ‘echo $PATH’ in both terminal and TeXmacs?

Dear jeroen,
Running echo $PATH in a terminal, yields

/Library/TeX/texbin:
/opt/local/bin:
/opt/local/sbin: 
/Users/matthias/opt/anaconda3/bin: 
/Users/matthias/opt/anaconda3/condabin: 
/Users/matthias/bin: 
/usr/local/bin:
/usr/bin: 
/bin: /usr/sbin: 
/sbin: 
/Library/TeX/texbin:
/opt/X11/bin: 
/Library/Apple/usr/bin

Running echo $PATH in a shell session within TeXmacs outputs

/usr/bin: 
/bin: 
/usr/sbin: 
/sbin: /Library/TeX/texbin: 
/opt/local/bin: 
/opt/local/sbin:
/Users/matthias/opt/anaconda3/bin:
/Users/matthias/opt/anaconda3/condabin:
/Users/matthias/bin:
/usr/local/bin: 
/usr/bin: 
/bin: 
/usr/sbin: 
/sbin: 
/Library/TeX/texbin: 
/opt/X11/bin: 
/Library/Apple/usr/bin: 
/Applications/TeXmacs.app/Contents/Resources/share/TeXmacs/bin:
/Users/matthias/.TeXmacs/plugins/matlab/bin: 
/Users/matthias/.TeXmacs/plugins/maxima/bin: 
/Users/matthias/.TeXmacs/plugins/octaveX/bin:
/Users/matthias/.TeXmacs/plugins/r/bin: 
/Applications/TeXmacs.app/Contents/Resources/share/TeXmacs/plugins/axiom/bin:

etc.

Cheers
Tilda

The pyenv plugin will help you solve the problem of managing different python versions in TeXmacs session.

Dear sadhen,

thanks for the info and the link. I will give the enhanced Python plugin with pyenv support a go when I have a bit more spare time at hand.

Cheers
Tilda