Skip to main content
Solved

Custom python dll not working in FME

  • February 16, 2016
  • 6 replies
  • 21 views

Forum|alt.badge.img+7

Hi all,

I am trying to use the module matplotlib inside FME itself so I can create histograms and store them on my hard drive.

I installed matplotlib in my standard Python 2.7 - 64 bit interpreter (the one that is used when you type 'python' in the command prompt) and I use this interpreter in pycharm (C:\\Python27\\python.exe) where everything works smoothly.

Now I would like to use this interpreter inside FME but I cannot get it working. I checked the internet thoroughly and tried already a lot. I didn't try to install matplotlib in the FME python interpreter since I use different versions of FME.

I tried using the following dlls:

C:\\Windows\\system32\\python27.dll (but this is 32-bit so it shouldn't work I guess...)

C:\\Windows\\SysWOW64\\python27.dll (but this generates an error)

In order to try to fix the first error, I checked if the correct paths are added to the environment variables (C:\\Python27;C:\\Python27\\Lib) which is the case.

I do not understand the second error.

Is there someone who encountered this problem and knows how to fix it?

 

For these tests, I used FME build 15250 (64bit version)

Thank you!

Best answer by david_r

Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\\Python27, see here for more info.

David

View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

david_r
Celebrity
  • Best Answer
  • February 16, 2016

Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\\Python27, see here for more info.

David


Forum|alt.badge.img+7
david_r wrote:

Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\\Python27, see here for more info.

David

Hi david_r

Thanks for the fast reaction!

Adding the PYTHONHOME-variable did the trick! The Workspaces completes the task. At the end however, an error is thrown everytime the program runs.

 

All pythoncode is executed but since this model is created for a customer, I would like to get rid of the error. Do you have an idea how I can do this?


david_r
Celebrity
  • February 16, 2016
jeroenstiers wrote:

Hi david_r

Thanks for the fast reaction!

Adding the PYTHONHOME-variable did the trick! The Workspaces completes the task. At the end however, an error is thrown everytime the program runs.

 

All pythoncode is executed but since this model is created for a customer, I would like to get rid of the error. Do you have an idea how I can do this?

Good to hear PYTHONHOME helped. That might indicate that your PATH points to another Python installation before the one in C:\\python27.

Regarding the error I see that there is a fatal Python error shown in the log window, but it is virtually impossible to tell where the problem lies without analysing/debugging the Python code in question. It might, however, be related to your PATH again and different versions of the MSVC libraries. Maybe try the steps outlined here and see if it helps.


Forum|alt.badge.img+7
david_r wrote:

Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\Python27, see here for more info.

David

The pythoncode that is used is just some 'dummy' code in order to test the matplotlib functionality (see below - just a creator and pythoncaller).

I tried reinstalling the Visual C++ Redistributial but that didn't fix the issue. 

I am unfortunately not allowed to update windows to the last version. Therefore I cannot test if that would do the trick. I tried the same code in FME 2015.0, 2015.1 and 2016 and they all result in the same error.

Thanks for the help!

import fme
import fmeobjects

import matplotlib.pyplot as plt

# Template Function interface:
def processFeature(feature):

    x = [12345]
    y = [10153187]
    nbBins = 5

    plt.hist(x, weights=y)
    plt.savefig('D:/histogram.png'

david_r
Celebrity
  • February 16, 2016
jeroenstiers wrote:

The pythoncode that is used is just some 'dummy' code in order to test the matplotlib functionality (see below - just a creator and pythoncaller).

I tried reinstalling the Visual C++ Redistributial but that didn't fix the issue. 

I am unfortunately not allowed to update windows to the last version. Therefore I cannot test if that would do the trick. I tried the same code in FME 2015.0, 2015.1 and 2016 and they all result in the same error.

Thanks for the help!

import fme
import fmeobjects

import matplotlib.pyplot as plt

# Template Function interface:
def processFeature(feature):

    x = [12345]
    y = [10153187]
    nbBins = 5

    plt.hist(x, weights=y)
    plt.savefig('D:/histogram.png'

Reinstalling MSVC won't help in 99% of cases. You'll probably have to progressively remove folders from your PATH environment variable until it starts working, and then you'll have found your culprit. Unfortunately, problems with different versions on the MSVC is well known and not limited to FME. Lots to be found on this issue with Google...

For your script, the only thing I can suggest is to add

plt.close() 

At the end of processFeatures. Let us know if it makes a difference.


Forum|alt.badge.img+7
david_r wrote:

Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\\Python27, see here for more info.

David

It did!

Everything works smoothly now.

Thank you very much David!


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