0

I created some simple modules for learning purposes containing simple classes and functions and tried to import it for the shell. Unfortunately TraceBack Error occurs.

I've checked os.getcwd() and I'm in the directory with all those modules. I also created modules with both pycharm and shell itself (open("filename","w") and stuff) and still python cannot find them.

Do you have any idea what's the reason of such matters?

import komendy

Error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'komendy'

They are in same folder:

>>> os.listdir()
['komendy.py', 'zmienne.py', 'venv', 'mordeczko.txt', 'mordo', '.idea']

Ideas?

martineau
  • 119,623
  • 25
  • 170
  • 301
DevVile
  • 59
  • 8

1 Answers1

0

You can import your library and its methods like this:

from komendy import *

Also check this: How to import other Python files?

Emrah Tema
  • 335
  • 3
  • 9