Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How can I import my user-defined module in a new project?

+6 votes
asked Jun 7, 2025 by Aarnav Arjun Krishna (180 points)
I have written a project named “calculator.py” , but if I create a new project and use

import calculator

It says module not found

What to do?

1 Answer

+1 vote
answered Jul 2, 2025 by digitalanilkr (160 points)

Add the module’s directory to sys.path

If calculator.py is in a different directory, you can manually add that directory to Python’s path:

python

import sys 

sys.path.append('/path/to/directory/of/calculator') 

import calculator

Replace '/path/to/directory/of/calculator' with the actual path.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...