Installing the Python geojson module on Mac OS X Yosemite to use with QGIS

心不动则不痛 提交于 2019-12-22 00:27:12

问题


I am new to using QGIS so this question might be real easy but I just can't find the answer anywhere online.

I need to use the module geojson in QGIS but it is not yet "installed". I've used import geojson and it says No module named geojson So my question is, how do I install geojson in QGIS or specifically PyQGIS?

I've already downloaded geojson from a website called geojson-1.0.9. Which folder should I copy geojson into so that PyQGIS can find the geojson python module.

Thanks!


回答1:


I managed to figure it out myself on how to do this.

I am using a Macbook Pro 13" mid-2012 running OS X Yosemite ver. 10.10.2

Python has already been installed on the Mac regardless of QGIS (QGIS Python console uses the original Mac Python installation), so to install a "module" (similar to "package" in R) you would have to download the module first. So in the case of "geojson":

  1. Download the tar module from: https://pypi.python.org/pypi/geojson/
  2. After downloading, the tar file would normally be in the Downloads folder.
  3. Run the "Terminal" app from the applications folder.
  4. Within the terminal app, navigate to the Downloads folder and type python setup.py install by using cd, for example cd Downloads/. Note that you might need to use sudo such as sudo python setup.py install if the folder is password-protected where you need to input the admin's password to proceed.
  5. The module would be installed in the appropriate folder i.e. the "site-packages' folder within the hidden python folder (either version 2.6 or 2.7). For me it was 2.7.

Now you can use the geojson module in QGIS. Test it by typing import geojson in the QGIS Python console.



来源:https://stackoverflow.com/questions/28927172/installing-the-python-geojson-module-on-mac-os-x-yosemite-to-use-with-qgis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!