r-spatial / RQGIS

RQGIS - integrating R with QGIS
GNU Lesser General Public License v3.0
189 stars 47 forks source link

error running open_app #69

Closed cmzambranat closed 6 years ago

cmzambranat commented 7 years ago

Hi,

I'm having an error with RQGIS. When I ran open_app() I get the following error:

Error in py_run_string_impl(code, local, convert) :
  ImportError: No module named _gdal

Detailed traceback:
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/osgeo/__init__.py", line 21, in <module>
  File "/usr/local/lib/python2.7/site-packages/osgeo/__init__.py", line 13, in swig_import_helper

I also tried to run find_algorithms("slope(.+)?aspect"), and in this case I got the following error:

Error in py_run_string_impl(code, local, convert) :
  NameError: name 'processing' is not defined

Detailed traceback:
  File "<string>", line 1, in <module>

I'm running mac OSX and I installed QGIS stable 2.14.14 through homebrew thanks!

pat-s commented 7 years ago

Have you installed gdal and gdal2 via homebrew?

Please also provide brew info qgis2-ltr

cmzambranat commented 7 years ago

Yes I did install gdal and gdal2 via homebrew. Here is the output from brew info qgis2-ltr

osgeo/osgeo4mac/qgis2-ltr: stable 2.14.14 (bottled), HEAD [keg-only]
Open Source Geographic Information System
https://www.qgis.org
/usr/local/Cellar/qgis2-ltr/2.14.14_1 (31,034 files, 597.5MB)
  Built from source on 2017-04-25 at 00:18:04 with: --with-grass --with-r --with-api-docs
From: https://github.com/osgeo/homebrew-osgeo4mac/blob/master/Formula/qgis2-ltr.rb
==> Dependencies
Build: cmake ✔, bison ✔, flex ✔
Required: qt-4 ✔, sip-qt4 ✔, pyqt-qt4 ✔, qca-qt4 ✔, qscintilla2-qt4 ✔, qwt-qt4 ✔, qwtpolar-qt4 ✔, gsl ✔, sqlite ✔, expat ✔, proj ✔, spatialindex ✔, fcgi ✔, gdal2 ✔, gdal2-python ✔, grass7 ✔, gettext ✔, pyspatialite ✔
Recommended: postgresql ✔
Optional: gpsbabel-qt4 ✘, grass6 ✘, homebrew/science/r ✔, saga-gis-lts ✘
==> Requirements
Required: unlinkedqgis2 ✔, python ✔
==> Options
--with-api-docs
    Build the API documentation with Doxygen and Graphviz
--with-gdal-1
    Build with GDAL/OGR v1.x instead of v2.x
--with-globe
    Build with Globe plugin, based upon osgEarth
--with-gpsbabel-qt4
    Build with gpsbabel-qt4 support
--with-grass
    Build with GRASS 7 integration plugin and Processing plugin support (or install grass-7x first)
--with-grass6
    Build extra GRASS 6 for Processing plugin
--with-isolation
    Isolate .app's environment to HOMEBREW_PREFIX, to coexist with other QGIS installs
--with-oracle
    Build extra Oracle geospatial database and raster support
--with-orfeo5
    Build extra Orfeo Toolbox for Processing plugin
--with-qspatialite
    Build QSpatialite Qt database driver
--with-r
    Build extra R for Processing plugin
--with-saga-gis
    Build extra Saga GIS for Processing plugin
--with-saga-gis-lts
    Build with saga-gis-lts support
--without-debug
    Disable debug build, which outputs info to system.log or console
--without-postgresql
    Build without current PostgreSQL client
--without-server
    Build without QGIS Server (qgis_mapserv.fcgi)
--HEAD
    Install HEAD version
==> Caveats
Bottles support only Homebrew's Python

QGIS is built as an application bundle. Environment variables for the
Homebrew prefix are embedded in QGIS.app:
  /usr/local/opt/qgis2-ltr/QGIS.app

You may also symlink QGIS.app into /Applications or ~/Applications:
  brew linkapps [--local]

To directly run the `QGIS.app/Contents/MacOS/QGIS` binary use the wrapper
script pre-defined with Homebrew prefix environment variables:
  /usr/local/opt/qgis2-ltr/bin/qgis2-ltr

NOTE: Your current PATH and PYTHONPATH environment variables are honored
      when launching via the wrapper script, while launching QGIS.app
      bundle they are not.

For standalone Python development, set the following environment variable:
  export PYTHONPATH=/usr/local/lib/qt-4/python2.7/site-packages:/usr/local/lib/python2.7/site-packages:$PYTHONPATH

Developer frameworks are installed in:
  /usr/local/opt/qgis2-ltr/lib/qgis-dev
  NOTE: not symlinked to HOMEBREW_PREFIX/Frameworks, which affects isolation.
        Use dyld -F option in CPPFLAGS/LDFLAGS when building other software.

If you have built GRASS 6.4.x or 7.0.x support for the Processing plugin set
the following in QGIS:
  Processing->Options: Providers->GRASS commands->GRASS folder to:
     /usr/local/opt/grass6/grass-base
  Processing->Options: Providers->GRASS GIS 7 commands->GRASS 7 folder to:
     /usr/local/opt/grass7/grass-base

This formula is keg-only, which means it was not symlinked into /usr/local,
because to allow for multiple QGIS installs.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/qgis2-ltr/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/qgis2-ltr/lib
pat-s commented 7 years ago

Please try brew link gdal2 --force. Running 10.12.x?

Also make sure to restart your R session.

cmzambranat commented 7 years ago

Thank you. I linked gdal2 as indicated, restarted R and still have the same error. I'm running 10.12.5. FYI, I'm getting the error when running R on the shell (iTerm2). However, I do not have any errors when I use RStudio and everything seems to work well.

pat-s commented 7 years ago

Sorry for the late response, I was without internet access during the last days.

FYI, I'm getting the error when running R on the shell (iTerm2). However, I do not have any errors when I use RStudio and everything seems to work well.

That's interesting, haven't heard of R problems in terminal but not in RStudio (just the other way round). Try R --vanilla and see if that works.

I'm also unsure about the underscore in the following error message (_gdal)

ImportError: No module named _gdal

Right now I have no clue why it does not work for you using the shell :/

cmzambranat commented 7 years ago

No worries, is good to be away from a computer! I tried R --vanilla and got the same error. I'll let you know if I find the problem. Meanwhile RQGIS is working fine in Rstudio. Thanks!!

pat-s commented 6 years ago

@cmzambranat Do you still have errors when using the command line? Feel free to re-open if needed.