Forums

New app, import error

Hello, I'm trying to create a new webapp, and every time I try to get to the website, I got the page "Something went wrong :-("

I looked into the error log, and it looks like it's an import error. Here the log error:

2023-01-06 12:23:04,948: Error running WSGI application
2023-01-06 12:23:04,952: ModuleNotFoundError: No module named 'environ'
2023-01-06 12:23:04,952:   File "/var/www/tradsim_eu_pythonanywhere_com_wsgi.py", line 12, in <module>
2023-01-06 12:23:04,952:     application = get_wsgi_application()
2023-01-06 12:23:04,952: 
2023-01-06 12:23:04,952:   File "/usr/local/lib/python3.8/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2023-01-06 12:23:04,953:     django.setup(set_prefix=False) 
2023-01-06 12:23:04,953: 
2023-01-06 12:23:04,953:   File "/usr/local/lib/python3.8/dist-packages/django/__init__.py", line 19, in setup
2023-01-06 12:23:04,953:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2023-01-06 12:23:04,953: 
2023-01-06 12:23:04,953:   File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 87, in __getattr__
2023-01-06 12:23:04,953:     self._setup(name)
2023-01-06 12:23:04,953: 
2023-01-06 12:23:04,954:   File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 74, in _setup
2023-01-06 12:23:04,954:     self._wrapped = Settings(settings_module)
2023-01-06 12:23:04,954: 
2023-01-06 12:23:04,954:   File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 183, in __init__
2023-01-06 12:23:04,954:     mod = importlib.import_module(self.SETTINGS_MODULE)
2023-01-06 12:23:04,954: 
2023-01-06 12:23:04,954:   File "/home/TradSim/TradSim_Site/src/SimuSite/settings.py", line 15, in <module>
2023-01-06 12:23:04,954:     import environ
2023-01-06 12:23:04,955: ***************************************************
2023-01-06 12:23:04,955: If you're seeing an import error and don't know why,
2023-01-06 12:23:04,955: we have a dedicated help page to help you debug: 
2023-01-06 12:23:04,955: https://help.pythonanywhere.com/pages/DebuggingImportError/
2023-01-06 12:23:04,955: ***************************************************

So it tells me I don't have the python-environ package installed. The first time this error happenned, that was true, so I installed it, and right now, I can't have access to the website or have another error. The package is well installed; in an interpretor I can do:

import environ

without having any error raise.

I can also, in my project's main app, do:

import settings
settings.DEBUG

And having the result I intended. So the package is really well installed. I already have, of course, reloaded many times the server.

Does anyone can help me please ? Thank you

I solved the problem by making a venv and running the website on it.

Glad you worked out a solution! I suspect that the underlying issue was that you had it installed for one Python version (say, 3.9) but your site was using Python 3.8. Different versions of Python have their own sets of installed packages.