简体   繁体   中英

import working locally but not after install usinging pip

I was trying to publish a package then install using pip3 and I got this error about importing a module:

  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/luanrv/codes/tmp/poc-pypkg/poc_pypkg/__main__.py", line 1, in <module>
    import utils
ModuleNotFoundError: No module named 'utils'

__main__ file:

import utils

if __name__ == '__main__':
    print('print from __main__')
    utils.display_msg()

the same happens for from utils ... and from .utils ... .

I don't get much time to understand python's packaging already. Would anyone aux me to solve this?

from poc_pypkg import utils worked as expected, locally and after publishing/installing using pip. I missed up and tried to run using python instead of python3 , what ran python2 causing the error on importing.

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