Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Ivan Monge
3,327 PointsTERM environment variable not set. Pycharm
So I am trying to run this code in my IDE. And yeah it runs fine for the letter refined code game. But I am getting this message in the console. "TERM environment variable not set." in every line it prints out. I am currently running Pycharm in my Mac computer. I know it has to do with this but still I don't understand.
def clear(): if os.name == 'nt': os.system('cls') else: os.system('clear')
5 Answers

Max Na
4,360 PointsHow to set up this variable via PyCharm?

Shane Conroy
11,032 PointsShana has the right answer, but I'll clarify how to add the right variable:
- If you haven't already, right click on the file you want to run, and click 'Run' (this will create a 'Run Configuration')
- Go to Run > Edit Configurations
- Next to the 'Environment Variables' field, click on the '...'
- Click the '+'
- On the right hand side of the new entry that's created after clicking '+', put 'TERM'
- On the left, put 'xterm-color'
- Click 'ok'.
Now when you run the script, there should be no error.

Qasa Lee
18,916 PointsIt works!

Jonathan Kuhl
26,133 PointsThanks for the instruction on how to set up. I don't get an error anymore, but my screen isn't clearing when I call the function. Maybe its because it's the output and not the terminal?
def clear():
os.system("cls" if os.name == "nt" else "clear")

Claudio Paladini
13,403 PointsI no longer get the error but the console does not clear. It does though from the terminal's session. :(

John Perry
Full Stack JavaScript Techdegree Graduate 41,012 PointsI think you got your rights and lefts backwards

Iain Simmons
Treehouse Moderator 32,305 PointsThat's an environment variable that your Mac's terminal application would use. Have a look at this question on Stack Overflow:
Add this to your profile:
export TERM=xterm-color

Zach Hudson
7,702 PointsIs this where it should be placed?
PyCharm > Preferences... > Build, Execution, Deployment > Console > Python Console (see image below)
Then in Environment Variables you would insert
export TERM=xterm-color

Shana HT
3,292 PointsIn the menu
Run > Edit Configurations
This brings up a new window, this is where you add the Environmental Variables

iulian borza
4,294 PointsI've tried adding the TERM variable to PyCharm and Eclipse with Python interpreter 2.7 and 3.5. It doesn't work for me. I'm using OSX. I've also export it in my terminal. I'm still getting the same error. Do you guys have other ideas?

Andrew Feather
Courses Plus Student 6,572 PointsAndrew Feather
Courses Plus Student 6,572 PointsIt's in your configuration for running the program. Right below where you link to the file it asks for environment variables.