问题
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":
- Download the tar module from: https://pypi.python.org/pypi/geojson/
- After downloading, the tar file would normally be in the Downloads folder.
- Run the "Terminal" app from the applications folder.
- Within the terminal app, navigate to the Downloads folder and type
python setup.py install
by usingcd
, for examplecd Downloads/
. Note that you might need to usesudo
such assudo python setup.py install
if the folder is password-protected where you need to input the admin's password to proceed. - 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