How can I start running Python files after closing the Ubuntu terminal?

June 29, 2017 297 views
Python Ubuntu 16.04

How can I start running Python files after closing the Ubuntu terminal? In other words how to get a prompt like this in Ubuntu termial: (my_env)rashid@rashid-DH55TC: ~/environments$: This will enable me to execute .py file.

1 Answer

Hi @RashidHameed

To execute .py files, simply run the command

python name_of_file.py

See this link for more details.

If you are asking about activating your virtual environment (so that in the terminal you see (my_env)rashid@rashid......... ) enable or activate your virtual environment using the command

$ source myenv/bin/activate

That will change

rashid@rashid-DH55TC: ~/environments$:

to

(my_env)rashid@rashid-DH55TC: ~/environments$:

(my_env) is the name of the virtual environment and it's presence shows that you are now in a virtual environment.

Have another answer? Share your knowledge.