Python Forum
Unable to import my own module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to import my own module
#1
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!
Reply
#2
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.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
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.
Reply
#4
Sorry, I misread what you were asking. If it's in the python path it should import
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  is import cointegration_analysis a recognized module mitcht33 1 424 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  problem in import module from other folder akbarza 5 1,380 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 711 Aug-06-2023, 01:09 AM
Last Post: aupres
  import module error tantony 5 3,433 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Import a module one step back of the path prathampatel9 1 1,065 Sep-21-2022, 01:34 PM
Last Post: snippsat
  Import a module for use in type hint? Milosz 0 1,478 Nov-08-2021, 06:49 PM
Last Post: Milosz
  Can't install nor import delorean module Tek 3 2,792 Oct-27-2021, 03:32 AM
Last Post: Tek
  Unable to import sklearn after installing any package ilango 0 1,179 Oct-25-2021, 07:03 AM
Last Post: ilango
  Unable to import Private Repo using setup.py Bob786 1 1,737 Sep-02-2021, 04:19 PM
Last Post: snippsat
  import module with syntax error Skaperen 7 5,254 Jun-22-2021, 10:38 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020