Question

Using Arcpy python3.x and additional libraries like pymssql

  • 4 April 2024
  • 4 replies
  • 32 views

Badge +4

Hello. We were using some extra libraries like pymssql and Arcpy in some shutdownscripts/startupscripts on our FME Server 2021  with python2.7  and integrated the libraries with sys.path.append ("C:\\Python27\\ArcGISXX.X\\Lib\\site-packages") like in this article https://support.safe.com/s/article/importing-arcpy-troubleshooting-ideas

This was working fine.


Now we should upgrade to python3.x and arcgis pro with a new Server/Flow Version.

I tried the old method but this isn’t working anymore. I found this article but for the server it’s a dead link https://support.safe.com/s/article/choosing-a-different-python-interpreter-installati

 

Is there a similar way for arcgis pro and python3 to use pymssql in FME Server/Flow?


4 replies

Userlevel 5

Since you’re using the ArcGIS Python interpreter, you’ll have to refer to the documentation for ArcGIS Pro, e.g. https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/add-a-package.htm

Badge +4

Since you’re using the ArcGIS Python interpreter, you’ll have to refer to the documentation for ArcGIS Pro, e.g. https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/add-a-package.htm

I have a clone of my ArcGIS Python Interpreter with the extra libraries, which i use for my non FME Python scripts. There i can import and use pymssql but i am not able to tell FME Server to use this clone. 

I read with a loop and sys.path all paths and the paths are:

D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\python37.zip
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\DLLs
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages
C:\Program Files\ArcGIS\Pro\bin
C:\Program Files\ArcGIS\Pro\Resources\ArcToolbox\Scripts
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages\future-0.18.2-py3.7.egg
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages\pytz-2020.1-py3.7.egg
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages\win32
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages\win32\lib
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages\Pythonwin
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages\pywin32_ctypes-0.2.0-py3.7.egg
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages\pywin32security
D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\lib\site-packages\sympy-1.5.1-py3.7.egg

Then with sys.append(...) i add all of the listed paths in my FME shutdownscripts but i am not able to import pymssql in the startup/shutdown scripts.

 

Userlevel 5

You’ll have to specify the ArcGIS Python interpreter in the workspace itself:

https://docs.safe.com/fme/html/FME-Form-Documentation/FME-Form/Workbench/Python-Compatibility.htm

Simply adding to sys.path[] is most probably not going to work.

Badge +4

You mean under Workspace Parameters\Scripting\Python Compatibility?

I already tried all modes.

i can import arcpy, but when i try to add pymssql i get the error:

 

60    2024-4-16 13:50:23 | Python Exception <ModuleNotFoundError>: No module named 'pymssql._pymssql'
61    2024-4-16 13:50:23 | Traceback (most recent call last):
62    2024-4-16 13:50:23 | File "<string>", line 37, in input
63    2024-4-16 13:50:23 | File "D:\Apps\PYScripts\ArcGISPro_Environments\arcgispro-py3-processingserver\Lib\site-packages\pymssql\__init__.py", line 3, in <module>
64    2024-4-16 13:50:23 | from ._pymssql import *
65    2024-4-16 13:50:23 | ModuleNotFoundError: No module named 'pymssql._pymssql'

But when i run a python script in pycharm and load pymssql it works, so it is in this directory and it is properly installed.

Reply