Skip to main content
Open

Better IDE for Python

Related products:Transformers

It would be great if FME could either use a better IDE for the Python Caller and startup/shutdown scripts or allow testing in an external IDE such as PyScripter. Right now there is no debugging capability and if you want to test your values you have to say something like:

print "value is",value

Then look for it in the log file. An internal line by line step through debugger would be useful, or to use an external editor that has a line by line step through debugger, enable PyScripter to understand:
import fme
import fmeobjects

21 replies

david_r
Evangelist
  • November 24, 2015
Hi

 

 

There is already an article about using the excellent PyCharm IDE with FME: Use PyCharm as FMEObjects Python IDE

 

 

Would that work for your use case?

 

 

On a more general note, I've had a lot of success with writing my modules as generic as possible, without using FMEobjects at all, only simple Pythonic data structures. It is then easy to integrate them into PythonCallers etc, using only a minimum of code to extract the necessary feature info (coordinates and/or key attributes) into they datastructures and pass them on to the modules. The great thing about this is the possibility of doing unit testing etc on your modules without having to rely on either FME or specific data.

 

 

David

 


bruceharold
Contributor
Forum|alt.badge.img+17
  • Contributor
  • November 24, 2015
My preference would be IDLE. It isn't great but it is always available.

 


Forum|alt.badge.img+5
  • November 27, 2015

Python is very powerfull but in FME (PythonCaller or PythonCreator) we need to have a real debugger.

In many cases, there is a indentation issue (grr), may be the best solution in the transformer is to use a better indentation for the Python language.

It will be very fun to debug the python scrypt with a Point break when the workbench is running

Suggestion to have two output for the PythonCaller or Creator:

  1. Output: everything works fine
  2. Output: exceptions

david_r
Evangelist
  • November 27, 2015

It's really easy to simulate the two output ports, though:

try: # Process feature here... feature.setAttribute('_error', 0) except: feature.setAttribute('_error', 1)

Then you check for '_error' using e.g. a Tester.

David


taojunabc
Participant
Forum|alt.badge.img+6
  • Participant
  • November 27, 2015

If you use PyScripter.You can configure it like this

  1. Tools ?Edit Startup Scripts
  2. Add the following code: import sys fmePypath=[r"C:\\apps\\FME\\fmeobjects\\python27",r"C:\\apps\\FME\\plugins",r"C:\\apps\\FME\\python",r"C:\\apps\\FME\\python\\python27"] sys.path.extend(fmePypath)
  3. Restart PyScripter PyScripter will be able to understand fmeobjects

'


  • November 30, 2015

This is a good solution but you would still be running your Python script outside of FME, correct? Everytime you work on your script and get it to work you would have to copy it and put it into the PythonCaller in your FME script. What I had in mind was that you open the PythonCaller and there is an option to open that script in your favorite IDE. When you save it in the IDE it saves to the PythonCaller.

One way I have emulated this is to write my code in my external Python editor and then import it in the PythonCaller.

import myPythonScript

If the script is in the same folder as the FME script or is on the PYTHONPATH, the FME Python interpreter will find it and execute it.


  • November 30, 2015

This is great to know about PyScripter. However, as I understand it, you would still be testing your script externally to FME and then you would have to copy it into the PythonCaller, correct?

See my comments to David's suggestion about PyCharm above.


david_r
Evangelist
  • December 2, 2015

I also use the "import myPythonModule" paradigm, it works nicely.

It also has the added benefit of forcing you to separate the algorithm (module) from your data (workspace), which I think is generally a good idea in itself.

Unit testing and debugging is also much easier when working on a free standing module, rather than integrated into e.g. a PythonCaller.


danilo_fme
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • December 28, 2015

I use PyCharm and liked very much.


Forum|alt.badge.img+5
  • February 1, 2016

Yes i know that :)

Thank you !


paalped
Contributor
Forum|alt.badge.img+5
  • Contributor
  • May 30, 2018

Yes to a new IDE!

But also these lines are very usefull:

logger = fmeobjects.FMELogFile() logger.logMessageString('Black_Info',0) logger.logMessageString(‘Blue_Warning’,1) logger.logMessageString('Red_Error',2)

paalped
Contributor
Forum|alt.badge.img+5
  • Contributor
  • May 30, 2018
Give us py linting!

Forum|alt.badge.img+1

Quick suggestion - a save button within the PythonCaller and PythonCreator that saves the workbench.


sigtill
Contributor
Forum|alt.badge.img+24
  • Contributor
  • December 17, 2019

Integrating the open source Atom would be great! https://atom.io/


ecthelion
Contributor
Forum|alt.badge.img+12
  • Contributor
  • December 7, 2020

Out of the few python IDEs I have used, pyScripter gets my vote for ease of use and also potential incorporation into FME Desktop. PyCharm might be too much of a sledgehammer.


warrendev
Enthusiast
Forum|alt.badge.img+23
  • Enthusiast
  • March 22, 2022

Yes please!


ronnie.utter
Contributor
Forum|alt.badge.img+9

I was just going to create this post and was so glad there already was one with so many votes. Yes please :)

 


mattwilkie
Supporter
Forum|alt.badge.img+10
  • Supporter
  • June 22, 2022

Over a thousand votes and still getting recent comments. Clearly there is user interest in this. 7 years since the idea was proposed, so also clearly there is a problem or two in implementing it. Would someone from Safe please provide some information on what gets in the way of using {IDE_of_choice}* for FME python scripts? There are some capable people in the user base. Maybe a description of the challenge to be surmounted will elicit some ideas or even code for doing so.

 

* my personal vote is Pyzo. Lightweight, self contained, easily switch between active interpreters without restarting, interactive and live variable exploration, cross platform.


jeand
Contributor
Forum|alt.badge.img+4
  • Contributor
  • February 7, 2023

Perhaps using our favorite Python software for developping?

https://community.safe.com/s/bridea/a0rDm000000Ccp7IAC/python-debugging


outlook
Contributor
Forum|alt.badge.img+3
  • Contributor
  • September 15, 2023

Pycharm would be great..


jwarren
Contributor
Forum|alt.badge.img+5
  • Contributor
  • December 2, 2024

Competitors have Jupyter notebooks built in as the python editor. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings