Solved

Where do I install python 3.6 packages to FME 2018?


The documentation for the PythonCaller points to this page to describe how to install python packages for FME: 

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Workbench/Workbench/Installing-Python-Packages.htm

At the bottom the target directory is listed as 

C:\Users\<user>\Documents\FME\Plugins\Python

But, in that directory are several subdirs: python27, python 34, python35. Do I install instead to a version-dependent subdir?

i.e.:

python -m pip install <mymodule> --target C:\Users\<user>\Documents\FME\Plugins\Python\python36
icon

Best answer by carsonlam 25 May 2018, 00:07

View original

6 replies

Badge

Hi

It doesn't really matter where you save you python 3.6. The only thing you need to do is to link the Python Interpreter to the right folder.

Go to tools, FME Options, Translation and in the python Interpreter section select your folder (Click on use a Custom Interpreter...)

I for example has saved my python package in AppData\\Local\\Programs\\Python\\Python36

I hope this helps you

Badge

If the Python package you're installing only has .py and works on both Python 2 and 3 with the same code ("universal"), then you can install directly into FME\\Plugins\\Python. If the Python package has different artifacts for different Python versions (such as those with binaries), then you should create a pythonXY subdirectory and install it there.

FME modifies the PYTHONPATH to include the pythonXY subdirectory corresponding to the version of Python in use.

If the Python package you're installing only has .py and works on both Python 2 and 3 with the same code ("universal"), then you can install directly into FME\Plugins\Python. If the Python package has different artifacts for different Python versions (such as those with binaries), then you should create a pythonXY subdirectory and install it there.

FME modifies the PYTHONPATH to include the pythonXY subdirectory corresponding to the version of Python in use.

@carsonlam, 

 

 

I've failed to get this to work for me as you've said with pythonXY sub directory, but I got it to work eventually. 

 

 

As background, I want to use a module called PyPDF2, but I don't want to install it to my system python. As a rule I use virtual envs. I've created a venv for testing: 

 

"C:\Users\ottadini\python-envs\pdfs"

 

I have both FME2017 and FME2018 installed, but am running 2018.

 

I've set my Preferred Python Interpreter to "FME Python 3.6+". 

 

I have python 3.6.5 installed on my system. 

 

I successfully installed a package with the following:

 

python -m pip install PyPDF2 --target C:\Users\ottadini\Documents\FME\Plugins\Python\python36
I can see it now in that directory.

 

 

I added the sys.path result to a feature attribute, and this is what it returned:

 

C:\apps\FME2018\/python
C:\apps\FME2018\/python/python27
C:\apps\FME2018\fmepython27\python27.zip
C:\apps\FME2018\fmepython27\DLLs
C:\apps\FME2018\fmepython27\lib
C:\apps\FME2018\fmepython27\lib\plat-win
C:\apps\FME2018\fmepython27\lib\lib-tk
C:\apps\FME2018
C:\apps\FME2018\fmepython27
C:\apps\FME2018\fmeobjects/python27
C:\Users\ottadini\AppData\Roaming\Safe Software\FME\Packages\18305-win32\transformers
C:\apps\FME2018\transformers
C:\Users\ottadini\Documents\FME\Transformers
C:\Users\ottadini\AppData\Roaming\Safe Software\FME\FME Store\Transformers
C:\Users\ottadini\AppData\Roaming\Safe Software\FME\Packages\18305-win32\python
C:\apps\FME2018\plugins
C:\apps\FME2018\plugins/python27
C:\apps\FME2018\plugins\python
C:\Users\ottadini\Documents\FME\Plugins\Python
C:\Users\ottadini\Documents\FME\Plugins\Python/python27 
Why does it show python 2.7 paths? Why does it not show 3.6 paths?

 

 

I am very confused. The python caller fails.

 

 

I moved the PyPDF2 to the next dir up the chain, and it does import the module. Maybe this is the expected behaviour? 

 

 

Ben

 

 

Badge
@carsonlam, 

 

 

I've failed to get this to work for me as you've said with pythonXY sub directory, but I got it to work eventually. 

 

 

As background, I want to use a module called PyPDF2, but I don't want to install it to my system python. As a rule I use virtual envs. I've created a venv for testing: 

 

"C:\Users\ottadini\python-envs\pdfs"

 

I have both FME2017 and FME2018 installed, but am running 2018.

 

I've set my Preferred Python Interpreter to "FME Python 3.6+". 

 

I have python 3.6.5 installed on my system. 

 

I successfully installed a package with the following:

 

python -m pip install PyPDF2 --target C:\Users\ottadini\Documents\FME\Plugins\Python\python36
I can see it now in that directory.

 

 

I added the sys.path result to a feature attribute, and this is what it returned:

 

C:\apps\FME2018\/python
C:\apps\FME2018\/python/python27
C:\apps\FME2018\fmepython27\python27.zip
C:\apps\FME2018\fmepython27\DLLs
C:\apps\FME2018\fmepython27\lib
C:\apps\FME2018\fmepython27\lib\plat-win
C:\apps\FME2018\fmepython27\lib\lib-tk
C:\apps\FME2018
C:\apps\FME2018\fmepython27
C:\apps\FME2018\fmeobjects/python27
C:\Users\ottadini\AppData\Roaming\Safe Software\FME\Packages\18305-win32\transformers
C:\apps\FME2018\transformers
C:\Users\ottadini\Documents\FME\Transformers
C:\Users\ottadini\AppData\Roaming\Safe Software\FME\FME Store\Transformers
C:\Users\ottadini\AppData\Roaming\Safe Software\FME\Packages\18305-win32\python
C:\apps\FME2018\plugins
C:\apps\FME2018\plugins/python27
C:\apps\FME2018\plugins\python
C:\Users\ottadini\Documents\FME\Plugins\Python
C:\Users\ottadini\Documents\FME\Plugins\Python/python27 
Why does it show python 2.7 paths? Why does it not show 3.6 paths?

 

 

I am very confused. The python caller fails.

 

 

I moved the PyPDF2 to the next dir up the chain, and it does import the module. Maybe this is the expected behaviour? 

 

 

Ben

 

 

The Python version loaded by each workspace is set under Navigator > Workspace Parameters > Scripting > Python Compatibility. Try setting it to Python 3.6+.

 

 

If the Python package you're installing only has .py and works on both Python 2 and 3 with the same code ("universal"), then you can install directly into FME\\Plugins\\Python. If the Python package has different artifacts for different Python versions (such as those with binaries), then you should create a pythonXY subdirectory and install it there.

FME modifies the PYTHONPATH to include the pythonXY subdirectory corresponding to the version of Python in use.

oh. that's embarrassing.

 

So that I'm really clear, the FME Options setting for python interpreter doesn't affect the current workspace, only new ones?

 

Badge
oh. that's embarrassing.

 

So that I'm really clear, the FME Options setting for python interpreter doesn't affect the current workspace, only new ones?

 

The setting in Workbench Options is sort of a default for newly-created workspaces. The Python version preference is then saved inside each workspace. FME tries its best to obey the Python setting inside the workspace.

 

Reply