简体   繁体   中英

In python, how to fix the ModuleNotFoundError: No module named '***' problem?

In python, I have a ABC.pye file which is encrypted by the package "sourcedefender".

To obtain the Function I need in the ABC.pye file, I use the following:

pip install sourcedefender
import sourcedefender
from ABC import Function

But then occurs the error,

Traceback (most recent call last):
  File "C:\Users\OPAC\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-7-8e557d63fc80>", line 1, in <module>
    from ABC import Function
  File "C:\Users\OPAC\AppData\Local\JetBrains\PyCharm 2020.1.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'ABC'

Is it because the file is not in the right folder?

I put the file in the path "C:\Users\OPAC\PycharmProjects\untitled", is it the correct path to put the ABC.pye?

Please tell me how to solve the ModuleNotFoundError: No module named '***' problem.

Thank you very much

You can try putting your python file in the lib folder in your python directory as that is where the standard library is installed, and i'm pretty sure the interpreter checks that folder for modules with the same name as your import.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM