barrust / mediawiki

MediaWiki API wrapper in python http://pymediawiki.readthedocs.io/en/latest/
MIT License
180 stars 29 forks source link

Error when launching QuickStart tests on MacOS #101

Closed ghost closed 3 years ago

ghost commented 3 years ago

I installed mediawiki on my machine (MacBook pro) running on MacOS Mojave, with python 3.9. Right after finishing installation, I ran the first exemple in README.rst. I get an error at wikipedia = MediaWiki() line. I get __init__() got an unexpected keyword argument 'encoding'. I am not sure the issue comes from mediawiki (actually, I have no clue what causes it), but I wanted to share it with you in case you might want to take a look.

barrust commented 3 years ago

This is strange. Can you provide the full traceback? Neither the mediawiki.py or the mediawikipage.py modules have an encoding in the init() function.

peterjschroeder commented 3 years ago

I'm getting this too with an old program I wrote that used to work.

Traceback (most recent call last):
  File "/home/peter/Dropbox/Projects/Software/wikisearch/./wikisearch.py", line 21, in <module>
    wikipedia = MediaWiki()
  File "/usr/local/lib/python3.9/dist-packages/mediawiki/mediawiki.py", line 121, in __init__
    self._get_site_info()
  File "/usr/local/lib/python3.9/dist-packages/mediawiki/mediawiki.py", line 826, in _get_site_info
    response = self.wiki_request(
  File "/usr/local/lib/python3.9/dist-packages/mediawiki/mediawiki.py", line 815, in wiki_request
    req = self._get_response(params)
  File "/usr/local/lib/python3.9/dist-packages/mediawiki/mediawiki.py", line 953, in _get_response
    return self._session.get(
  File "/usr/lib/python3/dist-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
TypeError: __init__() got an unexpected keyword argument 'encoding'
barrust commented 3 years ago

Apparently, python 3.9 removed the encoding keyword argument in python 3.9 which was deprecated previously. Not sure why this was working in some instances of python 3.9 but I am planning to remove python 2.7 support which required this parameter. I have a new branch which should be merged in later tonight and a new version on pypi that will hopefully resolve this issue.

barrust commented 3 years ago

Can people test the new v0.7.0 release?

The following should upgrade to the latest:

pip install --upgrade pymediawiki 
peterjschroeder commented 3 years ago

That worked, thank you.

ghost commented 3 years ago

Alright everything is now working fine for me but I think part of the issue came from me, my bad. I had it first installed by cloning the github repository and running $ python setup.py install (I couldn't manage to use pip). I can't be sure but I think it would only work properly inside the installation folder. The situation stayed the same after you upgraded the software (I'm sure of it in this case).

Now that I solved my pip issue (I just had to use pip3...), I uninstalled pymediawiki. Somehow I had to run the uninstallation twice since two versions were apparently installed at the same time. I reinstalled the last version with pip3 and everythingn is now working fine.

I hope my message is clear enough. I'm still a bit confused about what happened.