Skip to main content
Solved

How can I properly use an anaconda python environment in PythonCaller?

  • June 7, 2022
  • 3 replies
  • 268 views

Forum|alt.badge.img+2

I am trying to implement some python code that uses geopandas library, which I have installed in a local python environment on anaconda. I have made a few attempts to run it directly from PythonCaller transformer with no sucess: 

  • On fme desktop tools, I configured the fme python interpreter to get the .dll from the environment.
  • I also set the PYTHONHOME to the folder of the environment.

However, those configuration didn't work and I kept getting the error: No module named: "geopandas".

 

So, I also included this lines at the beginning of the code in PythonCaller:

import sys
sys.path.append(r"C:\Users\[username]\anaconda3\envs\[environment-name]\Lib\site-packages")

After that, I get a new error:

Python Exception <ModuleNotFoundError>: No module named 'pyproj._network'

 

I check on the "site-packages" folder and I have the pyproj package installed, so I don't know what could be causing this error,  in my anaconda environment the code runs without errors. 

 

Do you know what could be causing it?

Best answer by juandiegoboh

Hi David, thanks for sharing it, I've already read it. I did what people suggest in that post, unfortunately, my script still doesn't run correctly, I think it's due to a compatibility issue between the python of the anaconda install and FME.

 

But I have made it work, I have to recreate the libraries I have in my environment (ie leave out that env in my case) in the local fme python libraries installation (C:\\Users\\[username]\\Documents\\FME\\Plugins\\Python), which is not that easy as Geopandas has some problems in its dependencies when installing it using pip, then I updated to the latest version of FME (2022) and still had to change the python interpreter to use the version 3.9+, after that I successfully run the python script using geopandas.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, 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.

3 replies

david_r
Celebrity
  • 8391 replies
  • June 8, 2022

Forum|alt.badge.img+2
  • Author
  • 18 replies
  • Best Answer
  • June 8, 2022

Hi David, thanks for sharing it, I've already read it. I did what people suggest in that post, unfortunately, my script still doesn't run correctly, I think it's due to a compatibility issue between the python of the anaconda install and FME.

 

But I have made it work, I have to recreate the libraries I have in my environment (ie leave out that env in my case) in the local fme python libraries installation (C:\\Users\\[username]\\Documents\\FME\\Plugins\\Python), which is not that easy as Geopandas has some problems in its dependencies when installing it using pip, then I updated to the latest version of FME (2022) and still had to change the python interpreter to use the version 3.9+, after that I successfully run the python script using geopandas.


mattwilkie
Enthusiast
Forum|alt.badge.img+11
  • Enthusiast
  • 92 replies
  • October 3, 2022

Hi David, thanks for sharing it, I've already read it. I did what people suggest in that post, unfortunately, my script still doesn't run correctly, I think it's due to a compatibility issue between the python of the anaconda install and FME.

 

But I have made it work, I have to recreate the libraries I have in my environment (ie leave out that env in my case) in the local fme python libraries installation (C:\\Users\\[username]\\Documents\\FME\\Plugins\\Python), which is not that easy as Geopandas has some problems in its dependencies when installing it using pip, then I updated to the latest version of FME (2022) and still had to change the python interpreter to use the version 3.9+, after that I successfully run the python script using geopandas.

Maybe edit your reply so the solution isn't hidden behind the [expand post] link. The first couple of times I read this thread while looking for help I missed the important part.