[Tutor] Directories and Macintosh

Alan Gauld alan.gauld at btinternet.com
Fri May 29 20:47:13 CEST 2015


On 29/05/15 18:10, Barth, Dylan wrote:
> Hi there, I've never used this before and I'm very new to programming,

Welcome.

> I want to change my working directory in python
 > (permanently if at all possible)

What exactly do you mean by your working directory?
And "permanently" is a very long time, do you really
mean that?

Are you trying to
1) Change the folder that your python program looks
    for stuff by default?
2) Change the folder that your shell prompt is in?
3) Change the folder some GUI app users by default?
4) Something else?

Without significant effort Python can only change its
own environment. You can change the folder it thinks
is the current working directory, but not the folder
that the shell which launched Python thinks is it.
That is much harder to do.

> and nothing I can find online works,

Some examples of what you found online would help.
And how exactly they "didn't work". Did you get an error
message? Did you change directory at all, if so to what?
And what did you expect?

One thing you learn about programming is that you have
to be extremely specific and precise, there is no room
for guesswork.

> even when I've copy/pasted it into python.

How are you running Python? Are you using iPython
or the basic terminal application shell? Or maybe IDLE?

> I downloaded the anaconda package and the directory
 > right now goes into that folder instead of a different place.

Which directory do you mean?
I'm guessing that you mean when you start Python it uses
the anaconda install directory as its default? Is that right?

> No matter what I do, when I put in a path for it to look
 > at like "/Users/name/anaconda/lib/python2.7/Directory/datacopy?"
> It either gives back an error that it "User" is undefined or

Again being precise matters. Always cut n paste error messages
in full to your mails.

In this case did it say User or Users? Your path says Users
but you say the error says User... I'm guessing its a typo but
if they really are different that's "interesting" as Mr Spock
would say.

Also show us the code that generated this error. Otherwise
we are guessing at what is going on, and we don;t much like
guessing... its too unreliable.

Finally, maybe if you tell us *why* you are trying to change
the directory we can find a different method. It may just be a
system environment variable or similar that needs setting...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list