obsidian-execute-code
obsidian-execute-code copied to clipboard
Inconsistency with python version and modules (wrong python binary being run ?)
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)
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!
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
Without the --version option, If I try to import matplotlib, I get the error ModuleNotFoundError: No module named 'matplotlib'
(no "--version" option passed as argument)
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:
I strongly believe the execute-code plugin is not using the python binary I'm passing on the options as the python path
Could you try setting the path to another python installation on your system? I can't reproduce this error...
I made some changes in Release 0.10.0. Do your problems still occur?
@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.
I will close this issue now. Please reopen it when the problem reoccurs.