question about import module

Hi all,

I have a question about how to import a module developed my myself. First I just put the module in the same direction with the “main” class. However, the console shows “Can’t find module”. Then I tried to first upload the module to Connectport X5, then running the code. But it still saied “Can’t find module”. I know it is a simple question. Can anyone provide an answer ? :slight_smile:


Are you using the iDigi/Dia frame work, or is this your own Python code?

I do not ues iDigi/Dia framework. It is my own code.

try this to import file from the zip file

import sys
import module_name

Does the zip module file need to be .pyc file? Or .py file is also OK?

I tried it. However, the console reports “WEB is not defined”. How can I define it?

the ZIP can contain .py or .pyc files.

You of course need quotes around the string being appended to the path, so try:

import sys
import module_name