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.
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.
I ran into something similar and the answer from OP about namespace collision is what finally clued me in.
I was using the same name for both a sub-package (directory) and a module (file) within it.
For example I had this:
/opt/mylib/myapi
/opt/mylib/myapi/__init__.py
/opt/mylib/myapi/myapi_creds.py # gitignored file for user/pass
/opt/mylib/myapi/myapi.py # base module, load creds and connect
/opt/mylib/myapi/myapi_dostuff.py # call myapi.py and do work
The script 'myapi.py' imports credentials from myapi_creds.py via this statement:
from myapi.myapi_creds import my_user, my_pass
Testing the module 'myapi.py' resulted in this error:
$ ./myapi.py
Traceback (most recent call last):
File "./myapi.py", line 12, in <module>
from myapi.myapi_creds import my_user, my_pass
File "/opt/mylib/myapi/myapi.py", line 12, in <module>
from myapi.myapi_creds import my_user, my_pass
ModuleNotFoundError: No module named 'myapi.myapi_creds'; 'myapi' is not a package
The solution was to rename myapi.py to myapi_base.py so it's name does not collide with the sub-package name.
I took a look at this problem, and even though it is not exactly the same error that I encountered, it helped me solve it. I'll explain the situation I had, since I think some users might find this handy.
So, I was getting the following error log:
Traceback (most recent call last):
File "/home/kemal/Programming/Python/Preference_Articulation/LocalSearch/LS_apriori.py", line 1, in <module>
from LocalSearch.LocalSearch import LocalSearch
ModuleNotFoundError: No module named 'LocalSearch.LocalSearch'; 'LocalSearch' is not a package
The structure of my project is the following (using PyCharm):
View of project structure
The important thing to notice is that I separated my code into several folders, since it makes it more readable. Now, in the folder named LocalSearch I have 4 files, LocalSearch, LS_apriori and some 2 tests files (not relevant). When trying to run the file LS_apriori (which uses methods and classes from file LocalSearch) I was getting the error provided above. The code specifically is not important, and the way I handled the imports was the following:
from LocalSearch.LocalSearch import LocalSearch
The fix was simple. I renamed the py-file LocalSearch to Local_Search (just added an underscore). Afterwards, the error was gone.
So my problem was possessing a folder(package) with the same name as a file(module) inside it, which has a class inside it with the same name. Python didn't like that.
Having modules with the same name as packages inside them is fine however, I guess the class just added extra confusion.
I want to load .spydata files with load_dictionary. However for some reason it can't find the module. I thought this was something already in Spyder? I am running spyder 3.3.1 and I don't want to update it for compatibility reasons.
from spyder.utils.iofuncs import load_dictionary
ModuleNotFoundError: No module named 'spyder.utils.iofuncs'
I had the same problem. It seems that load_dictionary and save_dictionary was moved to the the module spyder_kernels, so
from spyder_kernels.utils.iofuncs import load_dictionary
must be used instead, see also
https://github.com/spyder-ide/spyder-kernels/blob/master/spyder_kernels/utils/iofuncs.py .
i am trying to run my main.py but i always get the same error.
ModuleNotFoundError: No module named 'ui.mainwindow'
I already tried with other commands like ui.MainWindow, ui.mainWindow, Ui.MainWindow but nothing worked. Can someone help me?
I have such short script:
import pygal
if __name__ == '__main__':
bar_chart = pygal.Bar()
and following error: AttributeError: 'module' object has no attribute 'Bar'
Do you have any idea what is wrong? Shall I configure some additional paths? I am using windows.
Thank you
If your script is named pygal.py, when you import pygal, it's going to import your script, not the pygal library you installed into your system site-packages. And your script obviously doesn't have a class named Bar.
The solution is simple: rename your script to something different. Like pygaltest.py or mypygal.py.
And make sure to look at the directory and see if there's a pygal.pyc left behind, which Python compiled from your pygal.py. If so, you have to delete that file.
I am running the code for pyzillow and I am encountering the following problem while importing the django library.
from django.contrib.gis.geos.error import GEOSException
ImportError: No module named django.contrib.gis.geos.error
Thoughts?
Follow the Django Docs,
find this line in settings and make it like this-
GEOS_LIBRARY_PATH = r'C:\Program Files\OSGeo4W64\bin\geos_c.dll'
This will solve the issue