How to clean up my Python Installation for a fresh start

后端 未结 4 492
旧巷少年郎
旧巷少年郎 2021-01-30 11:46

I\'m developing on Snow Leopard and going through the various \"how tos\" to get the MySQLdb package installed and working (uphill battle). Things are a mess and I\'d like to r

相关标签:
4条回答
  • 2021-01-30 12:14

    One thing you should not do is try to remove or change any of the Apple-supplied python files or links: they are in /usr/bin and /System/Library/Frameworks/Python.framework. These are part of OS X and managed by Apple. It is fine to clean up any unnecessary packages you have installed for that Python. They are in /Library/Python. If you installed a python.org Python and want to remove it, most of the files are in /Library/Frameworks/Python.framework. See here for complete instructions on how to remove them. And anything you installed into /usr/local is fair game.

    Using virtualenvs is a fine idea but it's slightly less important on OS X where the concept of framework builds makes it easier to support multiple Python versions than on some other platforms.

    The bigger issue, especially trying to use MySQL with Python, is getting all of the necessary non-Python libraries installed and built properly which is non-trivial given the variety of options available on OS X. For instance, depending on which Python instance and which OS X level running, you may need 32-bit or 64-bit or, possibly, both versions of things like the MySQL client libraries and the MySQLdb adapter. For that reason, I highly recommend using a complete solution from MacPorts. That way you have a good chance of getting all the right components built compatibly - and easily.

    If necessary, install the base MacPorts as described on the MacPorts website then:

    $ sudo port selfupdate
    $ sudo port install py26-mysql 
    

    and that will pull in and build everything you need and make it available in /opt/local/bin. There are also plenty of other ports available, for instance:

    $ sudo port install py26-virtualenv
    
    0 讨论(0)
  • 2021-01-30 12:19

    Virtualenv might still work for you. Install it, then create virtual python environments with the --no-site-packages option. This won't clean up your base system, but should allow you to develop in pretty good isolation from the base system.

    0 讨论(0)
  • 2021-01-30 12:19

    My experience doing development on MacOSX is that the directories for libraries and installation tools are just different enough to cause a lot of problems that you end up having to fix by hand. Eventually, your computer becomes a sketchy wasteland of files and folders duplicated all over the place in an effort to solve these problems. A lot of hand-tuned configuration files, too. The thought of getting my environment set up again from scratch gives me the chills.

    Then, when it's time to deploy, you've got to do it over again in reverse (unless you're deploying to an XServe, which is unlikely).

    Learn from my mistake: set up a Linux VM and do your development there. At least, run your development "server" there, even if you edit the code files on your Mac.

    0 讨论(0)
  • 2021-01-30 12:30

    when doing an "port selfupdate", rsync timesout with rsync.macports.org. There are mirror sites available to use.

    0 讨论(0)
提交回复
热议问题