2

My colleagues shared some programs and modules with me. I put them in ...../anaconda3/lib/python3.7/site-packages/pdbParser. Below show the content.

All programs(green), modules(green), and sub-directories(magneta) are under pdbParser

I set this directory in $PATH. However, when I run my program at another directory (let's say user directory), I received below error message.

  File "run.py", line 20, in <module>
    from pdbParser.pdbParser import pdbParser
  File "/<my system dir>/anaconda3/lib/python3.7/site-packages/pdbParser/__init__.py", line 14, in <module>
    from __pkginfo__ import __version__, __author__
ModuleNotFoundError: No module named '__pkginfo__'

Actually, my program (run.py) can call the module (pdbParser.py) in "//anaconda3/lib/python3.7/site-packages/pdbParser/" but the module (pkginfo.py) called by pdbParser.py cannot be found. I do not understand why it happened. I read related questions (1 and 2) in this community, but I could not get the issue fixed. Is there anything wrong on my end? Any further help and suggestion would be highly appreciated.

Leon
  • 444
  • 2
  • 15
  • The `.pyc` files indicate Python 2. Can you verify you are running Python 3.7? – Klaus D. Dec 28 '19 at 02:41
  • Yes. The programs shared from my colleagues were written by Python2. I tried to use them in Python 3. Honestly, I just started using Python two months ago. I have many things to learn. – Leon Dec 28 '19 at 02:44

1 Answers1

1

Can you fix the error syntax in the __init__.py file like this?

append .

from

from __pkginfo__ import __version__, __author__

to

from .__pkginfo__ import __version__, __author__
joonghyup cha
  • 624
  • 3
  • 12
  • 1
    Thanks! It works. May I know why I should add dot "." in the front of the module name? Thanks. – Leon Dec 28 '19 at 02:42