Ask coding questions

← Back to all posts
'Run' only works with
projectuwb1 (1)

Just started my python journey and realise that the 'Run' button only works when I have the file in my repl.

I tried to import a new file i added to the repl called "" by inserting import as the first line in but it will not run.

The error I receive is: Traceback (most recent call last):
File "", line 1, in <module>
ModuleNotFoundError: No module named ''; 'learn' is not a package

Anybody knows how I could run files other than

Answered by GermanScot (5) [earned 5 cycles]
View Answer
GermanScot (5)

1) did you add to your workspace?
2) did you import learn? You don't need the .py in the import statement

If you just use "import learn" then you need to use it like: learn.func(). -> better way
If you want to just use func(), then use from learn import * -> potential name clashes and unclarity

projectuwb1 (1)

Thanks for the response @GermanScot I think removing the .py seems to have solved it. I now have multiple file and they all run when I have them imported!

FloCal35 (667)

or you can import os and use os.system("python") and it just runs the file