EventRegistry / event-registry-python

Python package for API access to news articles and events in the Event Registry
http://eventregistry.org/
MIT License
232 stars 54 forks source link

ImportError: No module named 'EventRegistry' - Python3 #22

Closed grantgumina closed 7 years ago

grantgumina commented 7 years ago

EventRegistry doesn't seem to work out of the box with Python3 like promised. Here are the steps I took:

From the terminal: pip3 install eventregistry

Then python3 test.py (source code is included below - it's literally just importing and referencing EventRegistry)

Which gives me the following error:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from eventregistry import *
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/eventregistry/__init__.py", line 1, in <module>
    from EventRegistry import *
ImportError: No module named 'EventRegistry'

I can reproduce this behavior both on OSX 10.12.1 and Bash for Windows (although I'd expect the latter to be a bit buggy).

The test.py file is just the following:

from eventregistry import *

er = EventRegistry()
gregorleban commented 7 years ago

can I ask you to please the code in

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/eventregistry/init.py

from

from EventRegistry import *

to

from eventregistry import *

I think this is a leftover from old version where we used captialized folder name. Let me know if this works so that I commit the change (on Windows it works even as it is now).

grantgumina commented 7 years ago

Thanks Gregor. I did that, but now I'm getting the following:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    er = EventRegistry()
NameError: name 'EventRegistry' is not defined
gregorleban commented 7 years ago

Hi Grant, sorry, my bad - the problem was obviously somewhere else - on python 3, module imports don't work like in python 2 so I had to change the module to import like "from eventregistry.EventRegistry import *". I've uploaded the new version of the module so you can pull it from github or using pip.

Let me know if you have any more issues.

Best, Gregor

On Thu, Dec 8, 2016 at 8:36 AM, Grant J. Gumina notifications@github.com wrote:

Thanks Greg. I did that, but now I'm getting the following:

Traceback (most recent call last): File "test.py", line 3, in er = EventRegistry() NameError: name 'EventRegistry' is not defined

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gregorleban/EventRegistry/issues/22#issuecomment-265673185, or mute the thread https://github.com/notifications/unsubscribe-auth/AAxaurUdWMrTbDrfIVCcxo2_RaJALepwks5rF7OVgaJpZM4LHdwB .

--


Gregor

grantgumina commented 7 years ago

Yup that fixed it! Thanks for putting up with my noobishness, Gregor. Your library is excellent.

francesca8484 commented 5 years ago

Hello, I have the same problem of grantgumina. But, I can't solve. I have this python version: python 3.7. My code is the following one: import csv, os from eventregistry import* import datetime

er = EventRegistry(apiKey="myapi")

q = QueryArticlesIter(keywords=QueryItems.AND(["Migranti", "Africa", "Italia"]), \ dateStart=datetime.date(2019, 8, 1), dateEnd=datetime.date(2019, 9, 26), \ isDuplicateFilter="skipDuplicates", \ lang="ita") print(q) But, I receive the following error: Traceback (most recent call last): File "C:/Users/mandf/Desktop/csvpython/eventregistry.py", line 3, in from eventregistry import* File "C:\Users\mandf\Desktop\csvpython\eventregistry.py", line 6, in er = EventRegistry(apiKey="myapi") NameError: name 'EventRegistry' is not defined

What should I do?

gregorleban commented 5 years ago

It seems that you don't have the package installed. If you have multiple versions of python then make sure that you install the package in the same version where you are trying to use it.

On Thu, Sep 26, 2019 at 12:07 PM francesca8484 notifications@github.com wrote:

Hello, I have the same problem of grantgumina. But, I can't solve. I have this python version: python 3.7. My code is the following one: import csv, os from eventregistry import* import datetime

er = EventRegistry(apiKey="myapi")

q = QueryArticlesIter(keywords=QueryItems.AND(["Migranti", "Africa", "Italia"]), dateStart=datetime.date(2019, 8, 1), dateEnd=datetime.date(2019, 9, 26), isDuplicateFilter="skipDuplicates", lang="ita") print(q) But, I receive the following error: Traceback (most recent call last): File "C:/Users/mandf/Desktop/csvpython/eventregistry.py", line 3, in from eventregistry import* File "C:\Users\mandf\Desktop\csvpython\eventregistry.py", line 6, in er = EventRegistry(apiKey="myapi") NameError: name 'EventRegistry' is not defined

What should I do?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EventRegistry/event-registry-python/issues/22?email_source=notifications&email_token=AAGFVOU2S35S7Y2F6XAIWZTQLSCUTA5CNFSM4CY53QA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7VBP3Q#issuecomment-535435246, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGFVORMPVWFDH2RJ4XV4K3QLSCUTANCNFSM4CY53QAQ .

--

Gregor Leban Phone: +386-31-321-804 Skype: gregorleban