Python - module import breaks after running

Viewed 31

I have an issue where the module import workflow breaks after I start developing.

I am using Spyder (Editor, and the IPython Console) and a conda virtual env. I have a directory similar to:

C:\Users\xyz\Documents\Python Scripts\package\     
    __init__.py
    subpackage1/
        __init__.py
        moduleX.py
        moduleY.py
    extra_files/        
        moduleZ.py
    moduleA.py
    moduleB.py

PATH includes: C:\Users\xyz\Documents\Python Scripts\package

Step 1) When I first open Spyder, and in the IPython Console:

import moduleA
ModuleNotFoundError: No module named 'moduleA'

Step 2) In IPython:

import package.moduleA  <--- Works!

Step 3) Open moduleA.py in the Spyder editor. Run file. It runs through, no issues. <--- Works!

Step 4) Repeat step 2. In IPython:

import package.moduleA  <--- Doesnt Work!

    ModuleNotFoundError: No module named 'package'

Step 5) Repeat step 1...in the IPython Console:

import moduleA   <---- works!!

This is driving me nuts.... I've never had this issue before. I'm simply trying to make package available in my environment, and so I can do relative imports etc.

Thanks in advance!

0 Answers
Related