Solved

Python Compatibility issue with desktop 2019


Badge

Hello Team,

 

I have workbench with python start script, It was working fine with python compatibility Python27 in desktop 2015.

Now I have upgraded with desktop 2019 and python compatibility changed to Python3.7 which is throwing syntax error and it could not able to initialize the arcobjects. Could somebody help me to get out of this issue.

 

Thank...

icon

Best answer by david_r 23 March 2020, 17:57

View original

20 replies

Userlevel 4

If you want/need to stick with Python 3.x you'll probably have to migrate the code, it's not 100% compatibility between Python 2.x and 3.x

You can try using the automated upgrade tool described here, in many cases it will do everything for you:

https://docs.python.org/2/library/2to3.html

First export the Python code into separate .py files on your filesystem and go from there, before copying the result back into FME.

Userlevel 3
Badge +17

You mentioned arcobjects in your description. If you are calling arcpy in your Python startup script, note that there has been a change in behaviour between FME 2015 and 2019 in regards to load the arcpy library in FME.

In 2019, the Python Compatibility parameter within the workspace will need to be set to the appropriate choice based on the Esri product installed on the machine.

In addition, please check that FME is not configured to use a custom Python interpreter under Tools > FME Options > Translation > Python > Preferred Python Interpreter.

Badge

You mentioned arcobjects in your description. If you are calling arcpy in your Python startup script, note that there has been a change in behaviour between FME 2015 and 2019 in regards to load the arcpy library in FME.

In 2019, the Python Compatibility parameter within the workspace will need to be set to the appropriate choice based on the Esri product installed on the machine.

In addition, please check that FME is not configured to use a custom Python interpreter under Tools > FME Options > Translation > Python > Preferred Python Interpreter.

, I could not see option to select Esri ArcGIS Desktop Python(2.7) under preferred Python Interrupter, Could you please tell me how to enable that option.

 

 

 

Badge

If you want/need to stick with Python 3.x you'll probably have to migrate the code, it's not 100% compatibility between Python 2.x and 3.x

You can try using the automated upgrade tool described here, in many cases it will do everything for you:

https://docs.python.org/2/library/2to3.html

First export the Python code into separate .py files on your filesystem and go from there, before copying the result back into FME.

Thank , I made my code to compatible with Python37 but now I am facing issue with arcobjects. Inside my start script I am calling arcpy and fmeobjects modules which are throwing error as below.

 

2020-03-24 07:01:20| 20.1| 0.8|ERROR |Python Exception <ModuleNotFoundError>: No module named 'arcpy'

 

2020-03-24 07:01:20| 20.1| 0.0|ERROR |Error executing string `import arcpy, fmeobjects

 

Is arcobjects supports python37, If yes is there any configuration to be done to resolve this issue?

 

Userlevel 4

Thank , I made my code to compatible with Python37 but now I am facing issue with arcobjects. Inside my start script I am calling arcpy and fmeobjects modules which are throwing error as below.

 

2020-03-24 07:01:20| 20.1| 0.8|ERROR |Python Exception <ModuleNotFoundError>: No module named 'arcpy'

 

2020-03-24 07:01:20| 20.1| 0.0|ERROR |Error executing string `import arcpy, fmeobjects

 

Is arcobjects supports python37, If yes is there any configuration to be done to resolve this issue?

 

As far as I know, ESRI supports the following Python versions:

  • ArcGIS for Desktop: Python 2.7 only
  • ArcGIS Pro: Python 3.x only
Meaning that if you use FME with ArcGIS for Desktop, you cannot use anything else than Python 2.7, unfortunately.
Badge

If you want/need to stick with Python 3.x you'll probably have to migrate the code, it's not 100% compatibility between Python 2.x and 3.x

You can try using the automated upgrade tool described here, in many cases it will do everything for you:

https://docs.python.org/2/library/2to3.html

First export the Python code into separate .py files on your filesystem and go from there, before copying the result back into FME.

Oh my GOD, I was keep on digging this since two days. Thanks david.

One last question as i heard python27 is going to deprecate soon, then there will be impact on existing workbenches?

 

Userlevel 4

Oh my GOD, I was keep on digging this since two days. Thanks david.

One last question as i heard python27 is going to deprecate soon, then there will be impact on existing workbenches?

 

Strictly speaking, Python 2.7 was retired on 1 January 2020, so it's already been deprecated for some time. For FME, this currently means that the Python 2.7 libraries needs to be actively requested at installation, and that there are some warnings in place when working with workspaces configured for 2.7. However, apart from that everything currently works as before, and probably will for quite some time.

More info here: https://knowledge.safe.com/articles/71635/python-27-deprecation.html

Userlevel 3
Badge +17

, I could not see option to select Esri ArcGIS Desktop Python(2.7) under preferred Python Interrupter, Could you please tell me how to enable that option.

 

 

 

Hi @nag

My apologies for the delay in responding. I tested and it appears the Esri options under Preferred Python Interpreter (eg. Esri ArcGIS Desktop Python (2.7)) only appear when there is an installation of the appropriate Esri product on the same machine where FME is installed.

If these options do not appear in FME, I would suggest checking if ArcGIS Desktop is installed on the machine.

Badge

You mentioned arcobjects in your description. If you are calling arcpy in your Python startup script, note that there has been a change in behaviour between FME 2015 and 2019 in regards to load the arcpy library in FME.

In 2019, the Python Compatibility parameter within the workspace will need to be set to the appropriate choice based on the Esri product installed on the machine.

In addition, please check that FME is not configured to use a custom Python interpreter under Tools > FME Options > Translation > Python > Preferred Python Interpreter.

, Thanks for the follow-up update, Somehow I could able to resolve this issue by reinstalling ArcGIS desktop but still I am getting some compatibility errors. I have some queries related to installation could you please support me?

Query-1: While installing FME desktop again does we need to select the option to install Python27. Py27 was already installed along with the ArcGIS desktop installation.

Query-2: Is there any environmental variables needs to be set for calling arc objects through FME?

I could able to import arc objects libraries through python compiler, But from FME I was getting following error.

Before this error I was getting some different error like, No Module named win32com.client. To resolve this error I have installed pywin32-32bit. After installing Pywin32 error message changed to as above.

I could able to load arcobject libraries through python compiler as below,

Query-3: Is fme desktop and ArcGIS should be installed under the same drive?, I have installed ArcGIS desktop under C: drive and FMEDesktop unde E: drive. Is there any issue with this kind of installation?

 

Could you please help me out with some solution to fix this issue...

 

Thanks you...

Nag

Userlevel 4

, Thanks for the follow-up update, Somehow I could able to resolve this issue by reinstalling ArcGIS desktop but still I am getting some compatibility errors. I have some queries related to installation could you please support me?

Query-1: While installing FME desktop again does we need to select the option to install Python27. Py27 was already installed along with the ArcGIS desktop installation.

Query-2: Is there any environmental variables needs to be set for calling arc objects through FME?

I could able to import arc objects libraries through python compiler, But from FME I was getting following error.

Before this error I was getting some different error like, No Module named win32com.client. To resolve this error I have installed pywin32-32bit. After installing Pywin32 error message changed to as above.

I could able to load arcobject libraries through python compiler as below,

Query-3: Is fme desktop and ArcGIS should be installed under the same drive?, I have installed ArcGIS desktop under C: drive and FMEDesktop unde E: drive. Is there any issue with this kind of installation?

 

Could you please help me out with some solution to fix this issue...

 

Thanks you...

Nag

  1. Yes, you should install the FME Python 2.7 libraries if you plan on using FME with any type of Python 2.7, including the one from ESRI
  2. It should not be necessary. Make sure you use the 32-bit version of FME with ArcGIS for Desktop, however. If you want to use the 64-bit version of FME you will also have to install the ArcGIS Background Geoprocessing module.
  3. Separate drives are OK.
Badge

You mentioned arcobjects in your description. If you are calling arcpy in your Python startup script, note that there has been a change in behaviour between FME 2015 and 2019 in regards to load the arcpy library in FME.

In 2019, the Python Compatibility parameter within the workspace will need to be set to the appropriate choice based on the Esri product installed on the machine.

In addition, please check that FME is not configured to use a custom Python interpreter under Tools > FME Options > Translation > Python > Preferred Python Interpreter.

Hi @David_R, Still I am getting same error, even after installing fmepython27 libraries, I was using 64bit desktop and installed background geoprocessing tool as well. Below are the details of installed softwares And python interpreter updated as below,even I tried without custom interpreter, But result was same.

Userlevel 4

Hi @David_R, Still I am getting same error, even after installing fmepython27 libraries, I was using 64bit desktop and installed background geoprocessing tool as well. Below are the details of installed softwares And python interpreter updated as below,even I tried without custom interpreter, But result was same.

In the FME Options, try setting the "preferred Python interpreter" to Python 2.7 rather than the custom DLL.

Badge

You mentioned arcobjects in your description. If you are calling arcpy in your Python startup script, note that there has been a change in behaviour between FME 2015 and 2019 in regards to load the arcpy library in FME.

In 2019, the Python Compatibility parameter within the workspace will need to be set to the appropriate choice based on the Esri product installed on the machine.

In addition, please check that FME is not configured to use a custom Python interpreter under Tools > FME Options > Translation > Python > Preferred Python Interpreter.

@david_r still same error

Userlevel 4

@david_r still same error

You may need to contact Safe support on this one, unless someone else has an idea.

Userlevel 3
Badge +17

, Thanks for the follow-up update, Somehow I could able to resolve this issue by reinstalling ArcGIS desktop but still I am getting some compatibility errors. I have some queries related to installation could you please support me?

Query-1: While installing FME desktop again does we need to select the option to install Python27. Py27 was already installed along with the ArcGIS desktop installation.

Query-2: Is there any environmental variables needs to be set for calling arc objects through FME?

I could able to import arc objects libraries through python compiler, But from FME I was getting following error.

Before this error I was getting some different error like, No Module named win32com.client. To resolve this error I have installed pywin32-32bit. After installing Pywin32 error message changed to as above.

I could able to load arcobject libraries through python compiler as below,

Query-3: Is fme desktop and ArcGIS should be installed under the same drive?, I have installed ArcGIS desktop under C: drive and FMEDesktop unde E: drive. Is there any issue with this kind of installation?

 

Could you please help me out with some solution to fix this issue...

 

Thanks you...

Nag

@david_r has already provided excellent answers to your questions so I won't go into those in detail.

I think the error you are getting does not seem to be related to arcpy. Invalid class string is a win32com error--not arcpy. Depending on how your script is setup, FME has likely already imported arcpy in order to be able to run into that particular error as import statements like import arcpy are usually at the beginning of the script.

I have not worked with the win32com module personally so I don't know how to resolve that issue. I would recommend taking a look at the following StackExchange threads here and here for some suggestions.

I would also suggest testing the Python script outside of FME using a 64-bit Python interpreter (as you are using 64-bit FME Desktop). If the script does not work, then you will need to make changes to your system and not FME.

Badge

You mentioned arcobjects in your description. If you are calling arcpy in your Python startup script, note that there has been a change in behaviour between FME 2015 and 2019 in regards to load the arcpy library in FME.

In 2019, the Python Compatibility parameter within the workspace will need to be set to the appropriate choice based on the Esri product installed on the machine.

In addition, please check that FME is not configured to use a custom Python interpreter under Tools > FME Options > Translation > Python > Preferred Python Interpreter.

HI @david_r, can you refer any consultant from safe?

Thanks...

 

Userlevel 3
Badge +17

HI @david_r, can you refer any consultant from safe?

Thanks...

 

If you purchased FME through one of our partners, another option would be reaching out to them for support.

Userlevel 4

If you purchased FME through one of our partners, another option would be reaching out to them for support.

I agree, the partners should be your first line of support. If not, contact Safe support over the regular channels and they'll route your question internally to someone who can help.

It might be a good idea to point back to this thread, as there is a lot of useful information here now.
Badge

You mentioned arcobjects in your description. If you are calling arcpy in your Python startup script, note that there has been a change in behaviour between FME 2015 and 2019 in regards to load the arcpy library in FME.

In 2019, the Python Compatibility parameter within the workspace will need to be set to the appropriate choice based on the Esri product installed on the machine.

In addition, please check that FME is not configured to use a custom Python interpreter under Tools > FME Options > Translation > Python > Preferred Python Interpreter.

Thank You very much @Debbi and @david_r for your valuable time and support.

Somehow I could able to find the reason for this error, As debbi said it's issue with 3rd party application, Which was calling using python com objects. The following line was creating issues. Which means 3rd party application was not installed in my machine and com object is trying call the uninstalled application. In the other words if your system does not installed with excel application and your are trying to call excel application using com objects will throw the same error. Once again thanks for your support.

Userlevel 4

Thank You very much @Debbi and @david_r for your valuable time and support.

Somehow I could able to find the reason for this error, As debbi said it's issue with 3rd party application, Which was calling using python com objects. The following line was creating issues. Which means 3rd party application was not installed in my machine and com object is trying call the uninstalled application. In the other words if your system does not installed with excel application and your are trying to call excel application using com objects will throw the same error. Once again thanks for your support.

You're welcome, and thanks for sharing the solution, I'm sure that will be very helpful for anyone searching for the same issue later.

Reply