0

I am new to Ubuntu and am using the Anaconda platform to develop in Pyton and have a directory in /home/myPython/ containing .py files.

I would like to type a file name from the terminal (E.G. colors.py) and python would load and execute it.

I tried putting myPython\ files into what I thought was the path but that didn't help.

How should I proceed?

Fabby
  • 34,259
  • We are not going to give you support VIA email. This is a community based forum. Everyone in the community can participate as well as benefit in the forums. Private emails would loose out on steps done and steps missing. Please try to check the forum for answers to your question. You can also click on the share link just below your question and have a direct link to easily find this thread. When you log on, you'll also get a notice of messages , comments, and answers addressed to you in the heading of the page. – L. D. James Oct 08 '16 at 19:27

1 Answers1

1

There are two default paths you have available where you can put your programs. They are:

/usr/local/bin and ~/bin

The second of the two is a bin directory just below your home (i.e. /home/yourid/bin.

You would have to create it:

$ mkdir ~/bin

After it's created, the directory will automatically be included in your path on your next login.

You could either copy your programs to one of those two locations, or apply a symbolic link of your applicatons to one of those locations.

This is an example of placing a symbolic link:

$ ln -s /home/myPython/colors.py ~/bin/colors.py

Now you would have colors.py in your path and you can call it from anywhere. Using this procedure you could have your program packages any multiple directories. But the ones that you want to have readily available will be in your path by the symbolic link.

Alternatively as you asked, you can add a directory to your search path with this command:

$ export PATH=$PATH:/home/myPython

If you want this path to be effective on each boot append that line it to your ~/.bashrc file.

L. D. James
  • 25,036