Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TERM environment variable not set on Python code

I use Pycharm and when I run this Python code

os.system("clear")

I get this error:

TERM environment variable not set

In the Python Console, in the variables, I put

export TERM = xterm

What else can I do?

like image 414
darek_82 Avatar asked Aug 10 '16 08:08

darek_82


People also ask

How do you fix the environment variable is not set in Pycharm?

You need to go to the 'Run/Debug configuration' You can do this by going to 'Run' and selecting Edit configuration option on the title bar.

Can you set environment variables in Python?

With python code, environment variables can be set and manipulated. Setting the environment variable with code makes it more secure and it does not affect the running python script.

How do I permanently set an environment variable in Python?

To set and get environment variables in Python you can just use the os module: import os # Set environment variables os. environ['API_USER'] = 'username' os. environ['API_PASSWORD'] = 'secret' # Get environment variables USER = os.

How do you use an environment variable in a Python script?

The name of the environment variable is used as the index of the environ[] array to set or get the value of that variable. The get() function is used to get the value of a particular variable, and setdefault() function is used to set the value of the particular variable.


2 Answers

Try this configuration, i found it very helpful after struggling finding the solution and after configure the correct TERM variable.

enter image description here

like image 110
naor ohayon Avatar answered Sep 17 '22 12:09

naor ohayon


There is a simple solution for this. You need to go to the 'Run/Debug configuration' You can do this by going to 'Run' and selecting Edit configuration option on the title bar.

Then you can go to the environment variable option to add the environment variable 'TERM' and set the value as 'xterm-color'

you can check it out on this website. http://softwaretester.info/pycharm-term-environment-variable-not-set/

like image 21
Abhishek Gangadhar Avatar answered Sep 21 '22 12:09

Abhishek Gangadhar