Clean Up The Python Installation
It seems that python can be found in three different places in my Mac OS. See below. Is there anything wrong? Should I and how can I clean up my python installation without reinstalling the OS? In fact, I recently experience some strange behavior when using Python.
'/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/,
'/usr/local/lib/python2.7/site-packages',
'/Library/Python/2.7/site-packages',
Answer
What you need to do is update the paths in your .bashrc (or more likely .profile as you are on mac). This should be accessible from your home directory. ~/.profile and can be edited using nano.
You can then tell your terminal which set of libraries and version of python to use by adding the following. Note more than one may be added this way, so only have one bin directory with an executable python program!
export PATH=$PATH:/usr/local/lib/python2.7/site-packages
If you want to add other libraries / execute your own programs as if they were in the library or save yourself reinstalling everything, you can use the following:
export PYTHONPATH=/Library/Python/2.7/site-packages'
Finally if you wanted to run a script/preload libraries every time you open python, you can make a .pythonstartup file in your home directory as well.
export PYTHONSTARTUP=$HOME/.pythonstartup
As for cleaning up, most distributions tend to update you paths when they are installed, which is most likely what is causing your problems. So all you probably have to do is look at your .profile file and remove two of the three paths above.
Hope that helps!
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module