Error: use os.getenv(PORT, 8080) as the port and os.getenv(IP, 0.0.0.0)


#1

First a greeting to the community.
My programming skills are very basic. I’m starting now.
I made a small program that works well, but is usually only stop almost constantly.
getting the error:
Important: use os.getenv (PORT, 8080) as the port and os.getenv (IP 0.0.0.0) as the host in your scripts!
I looked at Google, etc, and not how to solve this problem.
You could help me or give me some advice.

Thank you


#2

You need to put PORT, 8080 and IP into quotes like so:

os.getenv(‘PORT’, ‘8080’)
os.getenv(‘IP’, ‘0.0.0.0’)

Hih


#3

Thanks for the reply. I did as you suggested and placed those lines in my “py” file in the beginning. Now I get the following message when I press “Run”:

Traceback (most recent call last):
File “/home/ubuntu/workspace/teacher_stats.py”, line 1, in
os.getenv(‘PORT’, ‘8080’)
NameError: name ‘os’ is not defined

What would you suggest next? Thanks again!


#4

A little too late, and i think you’ve found the answer but maybe i can help other people ^^
os.something means call the function ‘something’ in the module ‘os’ so you need to include the module ‘os’, else python cannot find the right function ^^
To do that you need to put the line ‘import os’ on top of your code :wink: