I have the following setup in my Spyder ide:
this program is showing the following exception:
runfile('C:/Users/pc/source/repos/python_package_and_module_test/main.py', wdir='C:/Users/pc/source/repos/python_package_and_module_test')
Reloaded modules: jupyter_client.session, zmq.eventloop, zmq.eventloop.ioloop, tornado.platform, tornado.platform.asyncio, tornado.gen, zmq.eventloop.zmqstream, jupyter_client.jsonutil, jupyter_client.adapter, spyder, spyder.pil_patch, PIL, PIL._version, PIL.Image, PIL.ImageMode, PIL.TiffTags, PIL._binary, PIL._util, PIL._imaging, cffi, cffi.api, cffi.lock, cffi.error, cffi.model
Traceback (most recent call last):
File "C:\Users\pc\source\repos\python_package_and_module_test\main.py", line 1, in <module>
import token.factoryclass as a
ModuleNotFoundError: No module named 'token.factoryclass'; 'token' is not a package
how can I resolve this issue?
source code:
my files are as follows:
.\
python_package_and_module_test.py
import token.factoryclass as a
var = a.factoryclass();
var.print();
factoryclass.py
class factoryclass(object):
def print(object):
print("factoryclass")
tokenclass.py
class tokenclass(object):
def print(object):
print("tokenclass")
factory\
factoryclass.py
class factoryclass(object):
def print(object):
print("factory.factoryclass")
tokenclass.py
class tokenclass(object):
def print(object):
print("factory.tokenclass")
token\
factoryclass.py
class factoryclass(object):
def print(object):
print("token.factoryclass")
tokenclass.py
class tokenclass(object):
def print(object):
print("token.tokenclass")
However, the same package and module structure is working in repl.it: