2

I'm using QGIS in Windows. I wrote some functions in a Python script (named my_script.py) that I would like to import in another Python script but each time I do that, I have this message, even if the scripts are in the same folder or if I changed the script folder paths in the QGIS preferences:

ModuleNotFoundError: No module named 'my_script'

I checked this post that proposes a solution involving modifying the console.py file of QGIS, but I cannot find this file on Windows.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Feb 3 at 11:00

1 Answer 1

3

If my_script.py is saved in C:\users\You\scripts, then in your other script do

import sys
sys.path.append("c:/users/You/scripts")
import my_script
answered Feb 3 at 11:28
1
  • Thanks soo much!! For some reason, I've already tried this trick and it didn't work but no problem this time. I probably misspelled something. Commented Feb 3 at 12:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.