0

I have a pythonscript TestOnly.py running successfully in Notepad++ (using a shortcut Shift-F9 to run it). TestOnly.py is in C:\Users\User\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts\myfolder

console.clear()
console.show()
from myDict import *
print months 

This works fine when myDict.py is in C:\Users\User\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts

But I want myDict.py to be in the same folder as TestOnly.py i.e. C:\Users\User\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts\myfolder

When I run TestOnly.py I get the following error:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\myFolder\TestOnly.py", line 3, in <module>
    from myDict import *
ImportError: No module named myDict


I have put an empty __init__.py file in both folders but they don't seem to have any effect. Can anyone explain a simple way of getting around this?

John Slee
  • 1
  • 1
  • Does this answer your question? [How to import a module given the full path?](https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path) – Toto Apr 27 '20 at 10:16

1 Answers1

0

The simple answer is:

Place an empty __init.py__ in myfolder

console.clear()
console.show()
from myfolder.myDict import *
print months
John Slee
  • 1
  • 1