1

So I changed $PATH to have Python2.5 work with Django back when it didn't support 2.6. Now I can't install much of anything through Python because I screwed up a lot of the internals. $PATH is now unnecessarily long because I didn't know what I was doing when I was adding to it. .profile doesn't contain any of the paths that I added using "export" in the terminal. I can't even install virtualenv. At this point, I feel as if I corrupted everything and would like to start from scratch without losing all of my data. I have everything backed up with Time Machine, but that will just keep the same settings that I had before anyways.

Is it completely hopeless now? Should I opt for a fresh OS reinstall using something other than Time Machine to back up all of my information? Or would this be an easy fix?

1
  • You shouldn't have to change the $PATH, you just have to execute: defaults write com.apple.versioner.python Version 2.5 from the command line Commented Sep 2, 2010 at 22:44

2 Answers 2

1

If you are using mac osx. Then my suggestion is that you use macports. The solution to do that is here.

You can then select to activate appropriate version by using python_select.

After that you can use virtualenv. This does work for me very well.

Sign up to request clarification or add additional context in comments.

1 Comment

Worked like a charm. I don't need virtualenv anymore. Thanks!
0

Why not just edit (with the text editor of your choice) the "dot files" that determine the settings of PATH in the environment? In your $HOME (probably /Users/youruserid) that includes (assuming your shell is the default one, bash) .bash_profile and .bashrc -- there's typically also a "system" one /etc/bashrc (no dot for this one;-). find ~ -type f -name '.*' -print0 | xargs -0 grep PATH tells you all the relevant files in your home directory and subtree that contain the string PATH (plus no doubt some more, such as history files and saved copies of old dotfiles) and can direct your editing. Be sure to log off and log on again to ensure that all relevant files are applied in order to test your changes.

Edit: to make this at all Python-relevant;-), here's a simple Python way to determine how to set the path so that exactly the same commands are executed in all cases as with the path setting you have now, but without wasteful duplication:

>>> x='''/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin'''
>>> s = set()
>>> l = list()
>>> for p in x.split(':'):
...   if p in s: continue
...   s.add(p)
...   l.append(p)
... 
>>> print ':'.join(l)
/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin
>>> 

7 Comments

Users home$ echo $PATH /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin ^That's my PATH variable. It's pretty messy, right? I'll try the find command that you showed me.
Just tried the find command and it didn't give me anything back.
There are many redundant paths in your "PATH" :) . Try removing them.
Try also cd /etc followed by grep PATH *. You really need to get your environment under control and removing duplicate entries will be a step in the right direction.
@Radeux, the problem is finding out which configuration files are causing the mess -- can't fix them unless you know what they are. There was an obvious typo in the find as I had typed it (closed quote after the -print0 rather than right after the .*!-), edited to fix it now, please try the sensible version now present;-).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.