ArcHydro-Wetland Identification Model - scikit-learn not recognized

2622
9
Jump to solution
07-06-2021 08:09 AM
CarolineChanEEC
New Contributor II

I am using ArcGIS Pro version 2.8.1 and the Wetland Identification Model process that is part of the ArcHydro toolbox. I have been following the steps within the documentation, and have successfully worked through the entire process. However, in a new iteration, when adding an additional predictor variable, I am getting this error:

('line 242', 'c:\\program files\\arcgis\\pro\\Resources\\ArcToolbox\\Scripts\\archydro\\trainrandomtrees.py', "ModuleNotFoundError: No module named 'sklearn'")

The project python environment clearly shows that sckikit-learn is installed.

I have tried recloning the default python and installing scikit-learn package to the new clone, but it still results in that error. 

I am at a loss as to what to try next.

1 Solution

Accepted Solutions
CarolineChanEEC
New Contributor II

This turned out to be a known bug with the ArcGIS Pro 2.8.1 update. BUG-000141015 - ArcGIS Pro 2.8.1 does not honor the active environment set through Python Package Manager, and causes the active environment to be reset to the base arcgispro-py3. This will be fixed in a future release.

this was the workaround that fixed the issue:

  1. Clone your Default environment normally through ArcGIS Pro's Python manager
  2. Install any libraries that you need to install for ArcHydro - at this point, the error should be reappearing if you attempted to use this environment now. 
  3. Instead of using this environment, close ArcGIS Pro after this cloning is complete & navigate in File Explorer to your default Python environment's directory on your machine - should be INSTALL_DIR\arcgis\bin\python\envs\arcgispro-py3. 
    1. Once in this directory, copy the _arcgisscripting.pyd file in 'arcgis\bin\python\envs\arcgispro-py3\Lib\site-packages\arcgisscripting\_arcgisscripting.pyd'
  4. Once you have copied that file, navigate to your cloned environment (C:\Users\xxxx\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone4\Lib\site-packages\arcgisscripting
    1. Rename the _arcgisscripting.pyd file to _arcgisscripting_old.pyd
    2. Then paste the arcgisscripting.pyd file from the default environment into this folder.

5. After the file has been pasted there, reopen ArcGIS Pro & attempt to use the cloned environment.

View solution in original post

9 Replies
DanPatterson
MVP Esteemed Contributor

Were you following this document for the install Caroline?

Arc Hydro - Wetland Identification Model.pdf (esri.com)


... sort of retired...
0 Kudos
CarolineChanEEC
New Contributor II

Yes, that is the document I followed to install the package.

0 Kudos
DanPatterson
MVP Esteemed Contributor

That is what I was checking.  If it is installed in your clone are you running the analysis from that environment?  Your error line looks like it is the base/main environment


... sort of retired...
0 Kudos
CarolineChanEEC
New Contributor II

Well yes, but I'm uncertain why every time I reopen the project, it returns to the default instead of the cloned environment.

CarolineChanEEC_0-1625668416150.png

 

0 Kudos
CarolineChanEEC
New Contributor II

I am still getting the error, despite double-checking that it is the cloned environment with scikit-learn installed.

 

0 Kudos
GinaO_Neil
Esri Contributor

Hi @CarolineChanEEC. Scikit-learn may be included in Pro 2.8.1 by default. Can you try the following and let me know the results?

-open the command prompt

- enter: proswap arcgispro-py3

- open pro

- open python window

- enter: import sklearn

- respond here with the output, it will either return an error or execute successfully

 

If that process does not return any errors, try executing the WIM process again in the open session of Pro. I'm thinking maybe sklearn already existed in your pro environment and by installing it "again" you could have changed the version of sklearn which may conflict with another library.

0 Kudos
CarolineChanEEC
New Contributor II

This turned out to be a known bug with the ArcGIS Pro 2.8.1 update. BUG-000141015 - ArcGIS Pro 2.8.1 does not honor the active environment set through Python Package Manager, and causes the active environment to be reset to the base arcgispro-py3. This will be fixed in a future release.

this was the workaround that fixed the issue:

  1. Clone your Default environment normally through ArcGIS Pro's Python manager
  2. Install any libraries that you need to install for ArcHydro - at this point, the error should be reappearing if you attempted to use this environment now. 
  3. Instead of using this environment, close ArcGIS Pro after this cloning is complete & navigate in File Explorer to your default Python environment's directory on your machine - should be INSTALL_DIR\arcgis\bin\python\envs\arcgispro-py3. 
    1. Once in this directory, copy the _arcgisscripting.pyd file in 'arcgis\bin\python\envs\arcgispro-py3\Lib\site-packages\arcgisscripting\_arcgisscripting.pyd'
  4. Once you have copied that file, navigate to your cloned environment (C:\Users\xxxx\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone4\Lib\site-packages\arcgisscripting
    1. Rename the _arcgisscripting.pyd file to _arcgisscripting_old.pyd
    2. Then paste the arcgisscripting.pyd file from the default environment into this folder.

5. After the file has been pasted there, reopen ArcGIS Pro & attempt to use the cloned environment.

GinaO_Neil
Esri Contributor

Thanks for sharing that! Did the WIM tool work as expected after that workaround?

0 Kudos
CarolineChanEEC
New Contributor II
Yep. Fixed it instantly.