Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

Ivan Monge
Ivan Monge
3,327 Points

TERM 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
Max Na
4,360 Points

How to set up this variable via PyCharm?

Andrew Feather
Andrew Feather
Courses Plus Student 6,572 Points

It's in your configuration for running the program. Right below where you link to the file it asks for environment variables.

Shane Conroy
PLUS
Shane Conroy
Courses Plus Student 11,032 Points

Shana has the right answer, but I'll clarify how to add the right variable:

  1. If you haven't already, right click on the file you want to run, and click 'Run' (this will create a 'Run Configuration')
  2. Go to Run > Edit Configurations
  3. Next to the 'Environment Variables' field, click on the '...'
  4. Click the '+'
  5. On the right hand side of the new entry that's created after clicking '+', put 'TERM'
  6. On the left, put 'xterm-color'
  7. Click 'ok'.

Now when you run the script, there should be no error.

Jonathan Kuhl
Jonathan Kuhl
26,133 Points

Thanks 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
Claudio Paladini
13,393 Points

I no longer get the error but the console does not clear. It does though from the terminal's session. :(

I think you got your rights and lefts backwards

That'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
Zach Hudson
7,702 Points

Is 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

alt text

Shana HT
Shana HT
3,292 Points

In the menu

Run > Edit Configurations

This brings up a new window, this is where you add the Environmental Variables

iulian borza
iulian borza
4,294 Points

I'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?