Geoprocessing service fails on importing python module

2486
3
Jump to solution
09-28-2016 12:15 AM
by Anonymous User
Not applicable

Hi.

I have a python script that imports the Beautiful Soup module, bs4 is installed on the server, and the script runs fine. However, when I publish this as a GP service (on the same server) and then try to run that tool as a GP service, I get the following error:

Error executing tool.............line 54, in from bs4 import BeautifulSoup ImportError: No module named bs4 Failed to execute..........

The only ESRI documentation I could find seemed to indicate that the module would not be 'consolidated' i.e. packaged with the script, but so long as the module was installed on the server then the GP service should run.

Can anyone suggest how to resolve this issue?

Thanks,

-Paul

Authoring geoprocessing tasks with Python scripts—Documentation | ArcGIS for Server 

Third-party modules

Third-party modules (any module that is not part of the core Python installation) are not consolidated. You need to ensure the module exists and runs correctly on the server. This does not apply to the numpy or matplotlib modules which are installed with ArcGIS Server.

0 Kudos
1 Solution

Accepted Solutions
JonathanQuinn
Esri Notable Contributor

Do you have the 64 bit version of the module on the Server machine?  If not, then that's the problem.  If you run the 64 bit version of IDLE and you can't import all of the modules used within your GP script, the GP service won't be able to import them either.  Make sure that you have all of the 64 bit versions of the modules within your script on the Server machine.

View solution in original post

0 Kudos
3 Replies
RebeccaStrauch__GISP
MVP Emeritus

Three thoughts:

- does ArcGIS Server have permissions to the folder where the mod is?

- maybe the folder can be registered in the datastore?

- or, maybe try copying the mod to the same folder as the MXD? or one of the GP folders ?

Just guessing.

0 Kudos
JonathanQuinn
Esri Notable Contributor

Do you have the 64 bit version of the module on the Server machine?  If not, then that's the problem.  If you run the 64 bit version of IDLE and you can't import all of the modules used within your GP script, the GP service won't be able to import them either.  Make sure that you have all of the 64 bit versions of the modules within your script on the Server machine.

0 Kudos
by Anonymous User
Not applicable

Hi Jonathan

Thanks for that - I think you've put me back on the right track...

I had thought of that and had supposedly checked it   I had run pip install from the 64 install location, and it said it was already installed. But after your comment, I double checked and did that again, and noticed that the install actually ran using the 32bit python install even though I ran pip from the command line while in the 64 install location.

Running the 64bit version of IDLE and trying to import the module did indeed fail as you suggested.

The easiest way in the end for me was to just manually copy the folders relating to the bs4 modules from the 32bit folder to the 64 bit folder, after which it seems to import fine.

C:\Python27\ArcGIS10.4\Lib\site-packages

C:\Python27\ArcGISx6410.4\Lib\site-packages

Thanks again.

Cheers,

-Paul

0 Kudos