0

actually I am trying to deploy my app in heroku and I always get this exception in the logs of heroku given that I am using python 3.6.3

2017-10-09T22:14:05.288072+00:00 heroku[web.1]: State changed from crashed 
to starting
2017-10-09T22:14:07.772902+00:00 heroku[web.1]: Starting process with 
command `python BookmarkServer.py`
2017-10-09T22:14:10.065235+00:00 app[web.1]:     import os.environ
2017-10-09T22:14:10.065239+00:00 app[web.1]: ModuleNotFoundError: No module 
named 'os.environ'; 'os' is not a package
2017-10-09T22:14:10.064976+00:00 app[web.1]: Traceback (most recent call 
last):
2017-10-09T22:14:10.064990+00:00 app[web.1]:   File "BookmarkServer.py", 
line 47, in <module>
2017-10-09T22:14:10.158467+00:00 heroku[web.1]: Process exited with status 1
2017-10-09T22:14:10.179803+00:00 heroku[web.1]: State changed from starting 
to crashed
Ahmed Adel
  • 39
  • 1
  • 8

2 Answers2

2

os.environ is not a module. It is a variable environ inside the os module. The import statement only imports the modules. Use it this way:

import os
print(os.environ)

Other usage:

from os import environ
print(environ)
Sergey Vasilyev
  • 3,919
  • 3
  • 26
  • 37
0

I was using Heroku/Django and got this error during a push.

I hadn't added django-environ to the requirements.txt.

I updated the file by: pip freeze > requirements.txt

Heroku then downloaded the module.