FME Version
Introduction
PyCharm Community Edition is a free and easy to use IDE for Python projects that can be setup to use FMEObjects.
Installation and Configuration
Download and install PyCharm Community edition from https://www.jetbrains.com/pycharm/download/
Python FMEObjects projects should not use FME's internal Python, so you may need to install a full version of Python from www.python.org. You can also use the Python interpreter installed by ArcGIS.
Configure Pycharm 2022.2 Community Edition for FMEObjects
2. Set Desired Python Interpreter
Note: The Python interpreter version must be one that is supported by the FME version used. The bit-version must also match. For example, FME 2022.x supports 64-bit Python 3.6-3.9 as 32-bit support has been dropped starting in this version.
If you want to use the arcpy module within your script, select the ArcGIS Python interpreter. You may have to add the interpreter to the interpreter list if it has not already been previously configured.
In the Add Python Interpreter dialog, select Virtualenv Environment from the left sidebar and select the Existing button. The default ArcGIS Pro Python 3 environment’s interpreter is located at:
C:\Program Files\ArcGIS\Pro\bin\Python\envs\argispro-py3\python.exe
Enter this path in the Interpreter field of the Add Python Interpreter dialog. Select OK to confirm these changes.
Note: This article uses ArcGIS Pro 3.0’s Python 3.9 interpreter with FME 2022.0. However, you may choose to use a different Python interpreter version as long as it is one that the FME installed supports. You will need to modify the instructions in the article to match the Python version used.
3. Add Library Paths to Use FMEObjects
dialog.
- <FME install>
- <FME install>\python
- <FME install>\python\<pythonVersion>
- For example, if using Python 3.9, add <FME install>\python\python39. If using Python 3.10, add <FME install>\python\python310, etc.
If using FME 2023.1 and older, the following path must also be added:
- <FME install>\fmeobjects\<pythonVersion>
-
- For example, if using Python 3.9, add <FME install>\fmeobjects\python39. If using Python 3.10, add <FME install>\fmeobjects\python310, etc.
-
In order to use fmebootstrap, one or more environment variables will need to be set when importing FME modules like fmeobjects in an external environment such as PyCharm.
FME_HOME = <FME install directory>
If the Python interpreter selected uses a Conda environment (eg. ArcGIS Pro Python, Spyder, etc.), the following environment variable will also need to be set:
CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
There are two ways these environment variables can be set in PyCharm:
Select Edit Configurations from the Python file dropdown on the top right-hand corner. In the Run/Debug Configurations dialog, add the environment variables that need to be set in the Environment Variables field. This option is more suited if the script is only going to be run in Pycharm.
The Python script should have a section that imports the os module, sets the environment variables, imports fmebootstrap, and then imports fmeobjects. This option is more suitable if the script is planned to be run outside PyCharm (ie. PyCharm is only the test environment).
import os # Modify the path if FME is installed in another location os.environ['FME_HOME'] = r"C:\Program Files\FME" os.environ['CONDA_DLL_SEARCH_MODIFICATION_ENABLE'] = str(1) import fmebootstrap import fmeobjects
Select Invalidate Caches… from the File menu and then restart PyCharm to update settings.
Using PyCharm
Note: this section assumes the environment variables were added using the PyCharm’s Edit/Debug Configuration option.
- Open project created above.
- Add FMEBootStrap reference: import fmebootstrap
- Add FMEObjects reference: import fmeobjects
- PyCharm will be able to import FMEObjects
Comments
0 comments
Please sign in to leave a comment.