0

When I started learning to program, I did not pay attention to where things were being installed, and did a lot of downloading, compiling and uninstalling without really knowing what I was doing. Mostly talking about python here, but there's a bit of Ruby too, and to be honest I don't know what else.

As a result, I have a great deal of cruft floating around my hard drive, and it's starting to cause problems.

So I really have 2 questions (on OSX):

1) Is there a good way to basically reset everything? Was thinking of creating a new user, and then just transferring the files I care about over, but I'm unclear if (or how to check) if there are system-level things that I need to fix. Completely reformatting would be a hassle, since there's an admin user created by my work that I can't touch.

2) Is there a good resource for best practices so I can avoid running into this problem in the future?

kevbonham
  • 999
  • 7
  • 24

1 Answers1

0

For python, use a virtual environment. This places you work in a seperate installation workplace for every different project. That is good practice using python. There are tons of good guidelines on how to do this. Of course there is a tool to make it (even) easier, called virtualenvwrapper. Using this, you simply say:

mkvirtualenv myproject

and from then on, you have a clean environment to install all kinds of dependencies into. If then later you start your computer again, you simply type workon myproject, and you continue with the same dependencies and install more or remove some, as you want. There is no contamination of the global environment. Python IDE`s provide are also able to recognize virtual environments for your projects.

Once created a virtualenv, you use pip or easy_install to setup and manage the required packages, and it is miraculously easy to store your requirements in a small text file and to recreate the entire environment if it were to be deleted or corrupted in any way or when migrating your project to another system, using pip freeze, which tells you the modules residing in your environment. Storing the output in a file, i.e. pip freeze > requirements.txt allows you to rebuild the requirements for the project in another environment, using pip install -r requirements.txt. This is all standard practice.

Also a virtualenvwrapper allows you to set custom environment variables for that specific project, without messing up the global environment or other environments, but I doubt you need this.

So there won't be immediate need to get rid of old/existing installations. However if you still want to do that out of cleaning frenzy or so, and you never had any admin rights, you can probably do pip freeze to see what is in there, and remove what you don't need. What you suggest might work, start with a new user. Just move the project files and setup a virtual environment for each project.

For ruby i am not the expert but a similar kind of functionality is provided by rvm.

Frido Emans
  • 5,120
  • 2
  • 27
  • 42
  • So if I do a virtual environment, it will basically start bare bones, not in the state the rest of my environment is currently at? – kevbonham Feb 03 '15 at 04:33
  • Still have a problem - I do have administrator access, and I've managed to fill up `/usr/local/bin` and other root-level things with random crap (including what looks like multiple python versions and installations, don't even remember that). When I say I "can't touch" work-installed admin profile, what I mean is "shouldn't touch". – kevbonham Feb 04 '15 at 16:33
  • I was able to use suggestions [here](http://stackoverflow.com/questions/3819449/how-to-uninstall-python-2-7-on-a-mac-os-x-10-6-4), except I just used `Library/Frameworks/Python.framework` rather than `...Python.framework/versions/2.7` for everything. Seemed to do the trick. – kevbonham Feb 04 '15 at 19:07
  • multiple versions of python should not be a problem. use `virtualenv -p /path/to/pythoninterpreter` to create an env use specific python version. System wide, the command `python` is generally bound to one version, i.e. 2.7 – Frido Emans Feb 05 '15 at 09:01
  • the /Library/Frameworks/Python.framework thing is explained here: https://docs.python.org/2/using/mac.html – Frido Emans Feb 05 '15 at 09:08