twibiral / obsidian-execute-code

Obsidian Plugin to execute code in a note.
MIT License
994 stars 61 forks source link

Python ModuleNotFoundError: No module named 'matplotlib' #317

Closed biscotty666 closed 3 months ago

biscotty666 commented 7 months ago

Hi,

Thank you for your plugin.

I am able to run vanilla python in Obsidian with your plugin, but cannot import any modules, even though they are installed on my system. I am using the flatpak for Obsidian, but it has access to all system files via flatseal. Any idea how to make this work?

Cheers, Brian

Kouroshdan commented 7 months ago

Hello Brian , It's not recommended to use flatpak for Obsidian. The Flatpak sandbox does not have access to system-wide Python modules, so that's why you're encountering this issue.

You have a few options to solve this:

Uninstall the Flatpak version of Obsidian and install the official one. Create a virtual environment and install your required modules there. This way, they will be accessible by Obsidian. If you prefer to continue using Flatpak, here's how you can create a virtual environment: ` Create a virtual environment python3 -m venv my_obsidian_venv

Activate the virtual environment source my_obsidian_venv/bin/activate

Install the required module (e.g., matplotlib) pip install matplotlib

Now, the matplotlib module should be accessible by Obsidian.` To ensure the Python executable used by your plugin is the one from your virtual environment, you can specify the path to it in your plugin settings.

twibiral commented 3 months ago

I will close this as solved, please reopen if the problem persists. Thanks @Kouroshdan for answering the issue!

biscotty666 commented 3 months ago

I'm embarrassed to have missed the reply. Thanks, I will install it natively.