在Mac OS X Yosemite上安装Python geojson模块以与QGIS一起使用 [英] Installing the Python geojson module on Mac OS X Yosemite to use with QGIS
问题描述
我刚开始使用QGIS,所以这个问题可能真的很容易,但我只是无法在网上找到答案.
I am new to using QGIS so this question might be real easy but I just can't find the answer anywhere online.
我需要在QGIS中使用模块geojson,但尚未安装".我用过import geojson
并说No module named geojson
所以我的问题是,如何在QGIS或专门的PyQGIS中安装geojson?
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?
我已经从名为geojson-1.0.9的网站下载了geojson.我应该将geojson
复制到哪个文件夹中,以便PyQGIS可以找到geojson python模块.
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.
谢谢!
推荐答案
我设法弄清楚了如何做到这一点.
I managed to figure it out myself on how to do this.
我正在使用2012年中运行Mac OS X Yosemite版本10.10.2的Macbook Pro 13"
I am using a Macbook Pro 13" mid-2012 running OS X Yosemite ver. 10.10.2
无论QGIS如何,Mac上都已经安装了Python(QGIS Python控制台使用原始的Mac Python安装),因此要安装模块"(类似于R中的"package"),则必须先下载模块.因此,对于"geojson":
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":
- 从以下位置下载tar模块: https://pypi.python.org/pypi/geojson/
- 下载后,tar文件通常位于下载"文件夹中.
- 从应用程序文件夹中运行终端"应用程序.
- 在终端应用程序中,导航到下载"文件夹,然后使用
cd
(例如,cd Downloads/
)键入python setup.py install
.请注意,如果文件夹受密码保护,则可能需要使用sudo
(例如sudo python setup.py install
),在该位置需要输入管理员密码才能继续操作. - 该模块将安装在适当的文件夹中,即隐藏的python文件夹(版本2.6或2.7)中的"site-packages"文件夹.对于我来说,它是2.7.
- 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.
现在,您可以在QGIS中使用geojson模块.通过在QGIS Python控制台中键入import geojson
对其进行测试.
Now you can use the geojson module in QGIS. Test it by typing import geojson
in the QGIS Python console.
这篇关于在Mac OS X Yosemite上安装Python geojson模块以与QGIS一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!