Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 - SafeConfigParser renamed to ConfigParser #24

Open
craigey opened this issue Nov 29, 2017 · 4 comments · May be fixed by #30
Open

Python3 - SafeConfigParser renamed to ConfigParser #24

craigey opened this issue Nov 29, 2017 · 4 comments · May be fixed by #30

Comments

@craigey
Copy link

craigey commented Nov 29, 2017

Hi,
I'm not well versed in the world of Python, so please forgive me if the below is nonsense or not anything you can help with:
I'm getting the following error when trying to run / setup kodi-alexa on my self-hosted Apache web server.

[Wed Nov 29 22:52:17.553193 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] mod_wsgi (pid=9684): Exception occurred processing WSGI script 'C:/Apache24/wsgi-scripts/kodi-alexa/alexa.wsgi'.
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] Traceback (most recent call last):\r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] File "C:/Apache24/wsgi-scripts/kodi-alexa/alexa.wsgi", line 4, in \r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] from alexa import app as application\r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] File "C:/Apache24/wsgi-scripts/kodi-alexa\alexa.py", line 18, in \r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] from kodi_voice import KodiConfigParser, Kodi\r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] File "C:\Python36\lib\site-packages\kodi_voice\init.py", line 1, in \r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] from .kodi import (\r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] File "C:\Python36\lib\site-packages\kodi_voice\kodi.py", line 22, in \r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] from ConfigParser import SafeConfigParser\r
[Wed Nov 29 22:52:17.556195 2017] [wsgi:error] [pid 9684:tid 1136] [client ::1:56613] ModuleNotFoundError: No module named 'ConfigParser'\r

From what I can see it's due to me running python 3+ rather than 2.7 as the SafeConfigParser was renamed to ConfigParser. I've tried getting my mod_wsgi to play nicely with python 2.7 & various versions of Apache, but I can't seem to find any other combination that works. Would it be possible to support Python 2 & 3? I've googled & apparently using the module "six" and a try catch block like below might work to support both versions - I'm not sure though.

Taken from:
https://stackoverflow.com/questions/14087598/python-3-importerror-no-module-named-configparser

try:
import configparser
except:
from six.moves import configparser

Is this feasible?

@m0ngr31
Copy link
Owner

m0ngr31 commented Nov 29, 2017

I think there might be some other things we need to do to make it work in Python 3 (not sure if all of the libraries work the same or have compatible upgrades), but if you want to try it out, let us know here if that works.

@craigey
Copy link
Author

craigey commented Nov 30, 2017

I cloned the repo & made a minor change (see below) to the kodi.py file & it seems to be working fine for me. I haven't committed the change as I didn't want to break anything for anyone using the older (v2) version of Python

import six
try:
import configparser
except:
#from six.moves import configparser
from six.moves.configparser import ConfigParser

from num2words import num2words
from fuzzywuzzy import fuzz, process
from configparser import SafeConfigParser
#from ConfigParser import SafeConfigParser
from .cache import KodiCache

@m0ngr31
Copy link
Owner

m0ngr31 commented Nov 30, 2017

You probably don't even need six right? Couldn't you just do:

try:
  from ConfigParser import SafeConfigParser
except:
  import configparser as SafeConfigParser

@craigey
Copy link
Author

craigey commented Nov 30, 2017

And that's why i'm not a python developer!
That worked fine for me.

:)

@jingai jingai linked a pull request Jun 6, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants