I'm installing locally the following Flask app: SolarPi. Since I had to install the raven package and there are pull requests and issues unanswered on the github repo, I assumed the code to be broken and not maintained anymore. Despite of my lack of proficiency on Flask and Python I decided to give it a shot and try and get it running.
When I run
$ (.env) python manage.py server
The code throws the following error:
Traceback (most recent call last):
File "manage.py", line 9, in <module>
from solarpi.app import create_app
File "/home/path/solarpi/solarpi/app.py", line 7, in <module>
from solarpi import public, weather, charts, statistics, tables
File "/home/path/solarpi/solarpi/public/__init__.py", line 4, in <module>
from . import views
File "/home/path/solarpi/solarpi/public/views.py", line 11, in <module>
from solarpi.public.helper import get_operating_days
File "/home/path/solarpi/solarpi/public/helper.py", line 4, in <module>
from pysolar.util import get_sunrise_sunset
File "/home/path/solarpi/.venv/lib/python2.7/site-packages/pysolar/__init__.py", line 1, in <module>
from . import \
File "/home/path/solarpi/.venv/lib/python2.7/site-packages/pysolar/radiation.py", line 21, in <module>
from . import numeric as math
File "/home/path/solarpi/.venv/lib/python2.7/site-packages/pysolar/numeric.py", line 140, in <module>
except ModuleNotFoundError:
NameError: name 'ModuleNotFoundError' is not defined
As it is possible to check on file numeric.py
from math import degrees, cos, sin, radians, tan, pi
from math import acos, atan, asin, atan2, exp, e
current_mod = 'math'
def globals_import_from(module, name, name_as):
"""
Does "from <module> import <name> as <name_as>" (globally)
"""
...
...
Bunch of defs
...
...
try:
import numpy
use_numpy()
except ModuleNotFoundError:
pass
the ModuleNotFoundError
is just an exception clause.
What is tricky here is the fact that the exception "NameError", that is raised when a local or global name is not found, catches an exception thrown by another built-in exception, in this case "ModuleNotFoundError". Since those exceptions are built-in, I assumed that the code is just written to python 3 and not python 2 as stated. Am I missing anything here that would not lead to refactoring the whole code?
ModuleNotFoundError
. 2.7 does not. You are using 2.7.ModuleNotFoundError
which is from python3. Am I suppose to rewrite the code to fallback to the previous version? If yes, do you know how would I do that?ImportError
instead? It is python2 compatible.