[GIS] Installing python xlw and xlrd libraries for QGIS on Mac OSX with Python 2.6

errormacpythonqgis-plugins

I am trying to use the XYtools plugin for QGIS (because copy-paste is not working with just one of my files?!), and I'm concerned that I actually just need to update my Python but not sure if doing so would disrupt anything. I've read all the posts on

install python xlw and xlrd libraries

errors, but most instructions seem to be for PC or assume Python version >= 2.7.

I installed QGIS about 4 months ago on a brand new machine running Yosimite, using the QGIS 2.12 built for Mac OS X Mountain Lion, Mavericks, Yosemite and El Capitan. Built with Qt Cocoa 4.8. The only Python I can find on my machine is version 2.6.

*update: In the meantime, I installed the Quick Export plugin and this gives me (almost) what I need. The strange thing is, even this appears to leave out several (seemingly) random entries in the table. I'm not entirely positive there isn't a problem with the project, as I have no problem copy-pasting from other projects. In any case, the question still stands (potentially for other plugins).

Best Answer

1) Yosemite comes with 2 versions of Python installed by default:

enter image description here

Python 2.7 (default), in the Terminal.app, type python and

enter image description here

Python 2.6, in the Terminal.app, type python2.6 and

enter image description here

The Kyng Chaos QGIS version uses /usr/bin/python and no other versions of Python (you can install other versions of Python if you want, 3.5 for examples)

enter image description here

2) To install a Python module, you need to know the Python "ecosystem", independent of the OS ("but most instructions seem to be for PC" is not relevant here.) -> look at New in How can I install pyproj into arcpy?

For example to install the xlrd module, go the Python Package Index (Pypi) and

  • Download xlrd-0.9.4.tar.gz, unzip/tar and open Terminal.app in the unzipped folder then

    python setup.py install (you need sudo python setup.py install because the folder /Library/Python/2.7/site-packages is protected)
    or
    python2.6 setup.py install (same)

  • The new way of installing modules is

    easy_install xlrd (with setuptools)
    or
    pip install xlrd (with pip)