Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
importing modules
#1
Hi,
I have an ETL project and 8 main directories. One of them has directories has my own written modules that need to be imported in scripts in order the code to work.
Those are all in the same folder but after endless trying the script in one directory won't import modules from the other.
I wrote it like this:

"from directory.modules import mymodule"
and it gives me an error
"no module directory"

Anyone have suggestion what can be causing this error and how should I fix it?
Reply
#2
That should work if directory is in the same folder as the file importing it, if you are running Python 3.0+. However, in 2.7 you would need an __init__.py file in directory.

To really diagnose this, it would help to know the exact file structure, the version you are running, and where you are running the code from.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  confusion on importing modules carter187 4 417 Mar-03-2024, 08:11 PM
Last Post: snippsat
  Importing modules from different folders Tomli 3 1,469 Jun-26-2022, 10:44 AM
Last Post: snippsat
  Importing modules issue mp3909 9 3,556 Jun-24-2020, 10:07 PM
Last Post: snippsat
  Importing Custom Modules in Python 3 Flexico 1 2,584 Aug-24-2019, 08:11 PM
Last Post: snippsat
  Trouble importing modules on a new python version snackman_barry 2 2,569 Jul-12-2019, 11:15 AM
Last Post: snackman_barry
  Importing all modules and using it rohitnirantar 2 2,553 Aug-28-2018, 08:15 PM
Last Post: snippsat
  Importing modules SBachar 2 3,055 Apr-06-2018, 09:08 PM
Last Post: snippsat
  Importing modules Pistolpete 2 2,707 Nov-29-2017, 05:24 PM
Last Post: nilamo
  Modules issue, pip3 download modules only to pyhton3.5.2 not the latest 3.6.1 bmohanraj91 6 8,440 May-25-2017, 08:15 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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