Python Forum
Unable to import my own module - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Unable to import my own module (/thread-26414.html)



Unable to import my own module - ThePhantom - Apr-30-2020

Hi everyone,

I am relatively new to python but I am trying to use it more extensively for post-processing of fluid mechanics data.
I am currently working under Windows 10 and I am using Spyder (Python 3.7). I created my own module Plottings.py which contains some plotting functions. Once I created the module I copied it in: C:\Users\ThePhantom\AppData\Local\Programs\Python\Python38-32\Lib\site-packages

Now, wherever I am located if I open Spyder and type:
import Plottings as myPlot
myPlot.
Pressing Tab I can actually see all the functions contained in Plottings (which means that the module is visible) BUT when I run it, it gave me back this error:
ModuleNotFoundError: No module named 'Plottings'
The only way I could solve this problem is to include Plottings.py in the folder where I am running the test case.
I appreciate your help. Thanks!


RE: Unable to import my own module - menator01 - Apr-30-2020

The approached I used made a folder in the same folder as the main script. Place my module in the new folder then to import, from my_new folder import my file.


RE: Unable to import my own module - ThePhantom - May-01-2020

Thanks for the answer. However, I would like to know if there is any way to import your module without having to have it in the same running folder.


RE: Unable to import my own module - menator01 - May-01-2020

Sorry, I misread what you were asking. If it's in the python path it should import