Python 'No module named' error; 'packa

2019-06-03 11:25发布

I'm trying to make a simple import and use the emailage third party library.

As per their documentation, the way to use their library is as follows:

pip install emailage-official

Then, simply import with:

from emailage.client import EmailageClient

The install works fine with pip - no errors. I double checked to see that the emailage package exists within the proper directory, and it does.

Package exists at:

C:\Users\aaron\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\emailage

This folder has (seemingly) the correct files with an __init__.py and everything. However, both pylint and command line interpreter throw me a 'No module named 'emailage.client'; 'emailage' is not a package' error.

The output of my sys.path is:

[... 
'C:\\Users\\aaron\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages'
...
]

So the directory where emailage is installed is a part of the path... and lastly I pip-installed numpy just to test if it worked properly. Numpy installed to the same site-packages folder as emailage, and it works fine when it is imported, so I'm stuck.

I don't typically use Python much, so any and all help would be appreciated.

1条回答
看我几分像从前
2楼-- · 2019-06-03 11:58

The issue was in the naming of my file.

I hastily named my file emailage.py and then tried to import from emailage.client.

I'm assuming that Python looked in my current directory and matched the names of the file I was working on before checking the installed third party libraries.

After renaming my file everything seems ok.

For others who run into similar problems -- beware of conflicting naming. Sometimes the simplest things trip you up the longest.

查看更多
登录 后发表回答