obsidian-execute-code icon indicating copy to clipboard operation
obsidian-execute-code copied to clipboard

Inconsistency with python version and modules (wrong python binary being run ?)

Open mateusfbsoares opened this issue 2 years ago • 3 comments

On options, I have set python path to be '/user/bin/python3'. When I run the following code

import sys
print(sys.executable)

it prints /usr/bin/python3


/usr/bin/python3 is version 3.10.4 and has matplotlib installed (as you can see on the image below) image


However, when running any script on obsidian-execute-code with the python parameter "--version" set under the plugin options, the result is always Python 3.6.9, and when importing matplotlib, it says ModuleNotFoundError: No module named 'matplotlib'


Any idea of what might solve? Thanks!

mateusfbsoares avatar Aug 11 '22 19:08 mateusfbsoares

Try removing the --version option and tell me about the result.

--version prints the version number and can't be used to execute scripts afaik

twibiral avatar Aug 16 '22 23:08 twibiral

Without the --version option, If I try to import matplotlib, I get the error ModuleNotFoundError: No module named 'matplotlib'

image (no "--version" option passed as argument)

image but error persists

however, on my terminal, I can import matplotlib using the python binary I'm passing on the python path option withtout errors: image image

I strongly believe the execute-code plugin is not using the python binary I'm passing on the options as the python path

mateusfbsoares avatar Aug 16 '22 23:08 mateusfbsoares

Could you try setting the path to another python installation on your system? I can't reproduce this error...

twibiral avatar Aug 24 '22 11:08 twibiral

I made some changes in Release 0.10.0. Do your problems still occur?

twibiral avatar Aug 29 '22 21:08 twibiral

@mateusfbsoares, you are using snap for Obsidian. Snap is a isolated/contained environment. It does not inherit any user's system files including binaries, libraries and python modules. It has its own isolated copy of python, pip and all required modules. Thus the user pip installation( and corresponding modules like matplotlib ) will never be visible to Obsidian.

Your conclusion that the Obsidian Python installation and System Python installation are different is absolutely CORRECT!

This problem is faced by 3 installation methods available for Linux ( AppImage , Flatpak and snap). Only working method is to install the .deb file from their website.

Looks like you are using Ubuntu, thus you can install DEB easily. Can you try DEB method and confirm if the problem persists.

@twibiral , it would be useful if we mention this in the README.

pspiagicw avatar Aug 31 '22 12:08 pspiagicw

I will close this issue now. Please reopen it when the problem reoccurs.

twibiral avatar Oct 13 '22 19:10 twibiral