InVEST 3.8.2 x 86 Installation problems

Hello everybody,
I am having some troubles trying to install the latest version on Invest (3.8.2) on windows 10.
I successfully installed all the required dependencies and PyQt5 on Python 3.8.2, but when I try to install natcap.invest I get this error message

Using cached Shapely-1.6.4.post2.tar.gz (225 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\isabella\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\isabella\\AppData\\Local\\Temp\\pip-install-nnjbqzz\\Shapely\\setup.py'"'"'; __file='"'"'C:\\Users\\isabella\\AppData\\Local\\Temp\\pip-install-_nnjbqzz\\Shapely\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file_, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\isabella\AppData\Local\Temp\pip-pip-egg-info-7c49d3lu'
         cwd: C:\Users\isabella\AppData\Local\Temp\pip-install-_nnjbqzz\Shapely\
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\isabella\AppData\Local\Temp\pip-install-_nnjbqzz\Shapely\setup.py", line 80, in <module>
        from shapely._buildcfg import geos_version_string, geos_version, \
      File "C:\Users\isabella\AppData\Local\Temp\pip-install-_nnjbqzz\Shapely\shapely\_buildcfg.py", line 200, in <module>
        lgeos = CDLL("geos_c.dll")
      File "c:\users\isabella\appdata\local\programs\python\python38\lib\ctypes\_init.py", line 373, in __init_
        self._handle = _dlopen(self._name, mode)
    FileNotFoundError: Could not find module 'geos_c.dll' (or one of its dependencies). Try using the full path with constructor syntax.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

The version of Shapely I installed is 1.7.0, as it was the only avilable for cp38
Anybody can help?

There were previously some issues with the shapely build, and so the log that you include here shows that the build process is attempting to build shapely version 1.6.4.post2 from source.

The right solution here will be for us to relax the constraint now that the build issues seem to be resolved, but there’s a workaround for you:

  1. Make sure you already have all of the natcap.invest python dependencies installed
  2. use pip install natcap.invest --no-deps to install natcap.invest. This will install the package without forcing the install of dependencies.

FYI There’s a small chance that this will work but then the import will fail. Let us know if this happens and we can see about an alternate approach.

Thank you for your help jdouglas, really appreciate! It did work, but yeah, when I try to run an invest command it returns me an error in the import of geoprocessing_core.

This is the error message:

C:\Users\isabella>invest --help
Traceback (most recent call last):
  File "c:\users\isabella\appdata\local\programs\python\python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\isabella\appdata\local\programs\python\python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\isabella\AppData\Local\Programs\Python\Python38\Scripts\invest.exe\_main_.py", line 4, in <module>
  File "c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages\natcap\invest\_init_.py", line 8, in <module>
    import pygeoprocessing
  File "c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages\pygeoprocessing\_init_.py", line 9, in <module>
    from . import geoprocessing
  File "c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages\pygeoprocessing\geoprocessing.py", line 15, in <module>
    from . import geoprocessing_core
ImportError: DLL load failed while importing geoprocessing_core: Impossibile trovare il modulo specificato.

Last part is in italian for some reason…

Well, no idea why the error is in Italian, but this error makes it sound like pygeoprocessing didn’t install correctly. Could you try reinstalling it? pip uninstall -y pygeoprocessing and then pip install "pygeoprocessing<2.0" should do the trick.

I tried pip install "pygeoprocessing<2.0" but I got this error,

Collecting Shapely!=1.7.0,>=1.6.4
  Using cached Shapely-1.6.4.post2.tar.gz (225 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\isabella\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\isabella\\AppData\\Local\\Temp\\pip-install-gs1ua301\\Shapely\\setup.py'"'"'; _file='"'"'C:\\Users\\isabella\\AppData\\Local\\Temp\\pip-install-gs1ua301\\Shapely\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file_, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\isabella\AppData\Local\Temp\pip-pip-egg-info-lapbutzs'
         cwd: C:\Users\isabella\AppData\Local\Temp\pip-install-gs1ua301\Shapely\
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\isabella\AppData\Local\Temp\pip-install-gs1ua301\Shapely\setup.py", line 80, in <module>
        from shapely._buildcfg import geos_version_string, geos_version, \
      File "C:\Users\isabella\AppData\Local\Temp\pip-install-gs1ua301\Shapely\shapely\_buildcfg.py", line 200, in <module>
        lgeos = CDLL("geos_c.dll")
      File "c:\users\isabella\appdata\local\programs\python\python38\lib\ctypes\_init.py", line 373, in __init_
        self._handle = _dlopen(self._name, mode)
    FileNotFoundError: Could not find module 'geos_c.dll' (or one of its dependencies). Try using the full path with constructor syntax.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

it appear that every version below 2.0 are incompatible with python 3.8.2. I downloaded the wheel file of the 2.0 on pypi.org and installed it, and I got this

C:\Users\isabella>pip install C:\Users\isabella\Downloads\pygeoprocessing-2.0.0-cp38-cp38-win_amd64.whl
Processing c:\users\isabella\downloads\pygeoprocessing-2.0.0-cp38-cp38-win_amd64.whl
Requirement already satisfied: Cython in c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages (from pygeoprocessing==2.0.0) (0.29.19)
Requirement already satisfied: Rtree>=0.8.3 in c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages (from pygeoprocessing==2.0.0) (0.9.4)
Requirement already satisfied: scipy!=0.19.1,>=0.14.1 in c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages (from pygeoprocessing==2.0.0) (1.4.1)
Requirement already satisfied: numpy>=1.10.1 in c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages (from pygeoprocessing==2.0.0) (1.18.4)
Requirement already satisfied: Shapely>=1.6.4 in c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages (from pygeoprocessing==2.0.0) (1.7.0)
Requirement already satisfied: GDAL>=3.0.4 in c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages (from pygeoprocessing==2.0.0) (3.0.4)
Requirement already satisfied: setuptools in c:\users\isabella\appdata\local\programs\python\python38\lib\site-packages (from Rtree>=0.8.3->pygeoprocessing==2.0.0) (41.2.0)
ERROR: natcap-invest 3.8.2 has requirement GDAL<3.0,>=2.0, but you'll have gdal 3.0.4 which is incompatible.
ERROR: natcap-invest 3.8.2 has requirement Shapely<1.7.0,>=1.6.4, but you'll have shapely 1.7.0 which is incompatible.
Installing collected packages: pygeoprocessing
Successfully installed pygeoprocessing-2.0.0

then when I try to run invest --help it returns the same error as before.

The error message says that GDAL and Shapely as well aren’t the required versions for inVEST, but I couldn’t install the required versions as they are incompatible with the Python I am running

Hi @Isabel26,

I’m sorry for the inconvenience here! I had thought that we might be able to get around these installation issues more easily, but you’re right that the Gohlke python libs page only has limited support for certain GDAL and shapely versions for python 3.8. We are actively working on making sure InVEST works well on python 3.8, and we’re simultaneously working on updating to GDAL 3 as well. I’d expect that we have a compatible development release for that ready within a couple weeks.

In the short term, I see two possible ways to work around these issues:

  1. If you’d like to continue to use python 3.8, I’d suggest trying to use conda as a package manager, particularly with the conda-forge channel, to install GDAL, numpy, shapely, rtree and PySide2, and then use pip to install the other dependencies. You’ll need a compiler to install pygeoprocessing<2 and natcap.invest.
  2. You could install python 3.7 in order to pip install natcap.invest==3.8.2. InVEST 3.8 (and all dependencies) are compatible with python 3.7, and we use it for our own binary builds of InVEST as well.

But also, could you just confirm that you’re hoping to use the python API for scripting? If you only need to be able to use the InVEST User Interface, the prebuilt binaries we have available on our website will be far easier to set up.

Hope this helps!
James

1 Like

Hi, yeah, I really needed just that for now, thanks a lot. The installation with python 3.7 finally worked fine though, I might try to use InVEST for scripting later on. Thank you for your time, that was really helpful!

2 Likes

Hi jdouglass,

I am trying to install invest in Ubuntu 18.04. I use Pycharm to install Invest 3.8.2, using python 3.7 in an anaconda3 interpreter. However, when I try to launch invest it says that “pyqt5” could not be found. I reinstalled pyqt5 version 5.15.0. in my project interpreter, but I am still receiving the same message.

Any guidance with this issue would be appreciated.
Thanks,
Sergio

Blockquote

invest launch

/home/sergio/anaconda3/lib/python3.7/site-packages/qtpy/init.py:211: RuntimeWarning: Selected binding “pyqt5” could not be found, using “pyside2”
‘using “{}”’.format(initial_api, API), RuntimeWarning)
qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, xcb.

Aborted (core dumped)

Blockquote

Hi @sergio,

To get the UI working, you’ll need a few extra packages:

qtpy>1.3
qtawesome
requests
PySide2

However you want to install those should be fine, including into your existing conda environment. With any luck, that’ll sidestep the qt plugin issue as well.

Let us know how this goes!
James

Hi James,

Thanks for your prompt reply. I reinstalled all these required packages, but I got the same error. Then, I tried installing everything, including natcap, in a virtual env. Unfortunately, I am still receiving the same error message. I want to run in a batch fashion the swy, carbon, and sdr models. Is there an easier way to use this model in a Linux machine?

Thanks,
Sergio

Well, for batch processing, the UI isn’t required … you can just import natcap.invest within a python script and start executing some of the model as desired. Here’s an example workflow for getting that to work (albeit in a Windows environment): https://invest.readthedocs.io/en/latest/scripting.html

There are a couple of options to get the UI working:

  1. You could continue to work through setting thing up natively on Linux. There isn’t a single installation process, though, so we’ll just need to keep debugging until it works as expected.
  2. You could use WINE to install and run the latest InVEST windows binaries.

On the linux side of things, if everything is already installed, then it looks like we need to force InVEST to use PySide2. If PySide2 is installed, this can be done by setting the QT_API environment variable such as:

$ QT_API=pyside2 invest launch
1 Like

Hi James,

I tried setting the QT_API environment variable as you suggested, I also tried many other tricks that I found on the web, but still, the IU did not work. So, I gave up. The good news is that the models are running fine without its GUI, and so far the suggested workflow for batch processing is working as expected in my Linux computer.

Thanks for your valuable help!

Sergio

1 Like

Thanks for letting us know!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.