MapInfo Pro

 View Only
  • 1.  Getting Started using Python In MapInfo Pro

    Posted 04-29-2020 13:41
    Edited by Peter Møller 08-18-2021 09:18
    Here is some quick info on how to get started using Python in MapInfo Pro.

    Starting with v2019.1, Python is installed and ready to use out of the 'box'.

    See my post here for ideas on what you could do with python and why: What's the Story on Python in MapInfo Pro.

    First, you will want to get two Python help applications from the MapInfo Marketplace.
    The easiest way to do that is to type 'python' into the quicksearch toolbar. (It now also searches the Marketplace.)
    Type Ctrl+Q then type python:

    You will see two Python applications:

    Python Console

    You can use any Python IDE to develop your code, but we are providing a small Python Console via the MapInfo Marketplace to help with interactively editing and running small python scripts. It supports syntax highlighting and intellisense.

    Python Quick Start
    This add-in has many python code examples from simple to complex.
    In addition, in includes reference materials and links to web sites and documentation to help you get going.

    Click on the search results and the Marketplace window will open in Pro. Simply click the Install Product button.

    Then do the same for the Python Quick Start add-in.

    Here is a screen shot of the reference page:

    There are over 30 examples in various categories, and you can search for specific text like a mapbasic or python keyword you want to see how to use.

    Here is one example that tells Pro to convert a .csv file to a MapInfo Table:

    The edit button opens up the script into the Python Console.

    The Run button executes the script.

    Feel free to come here with questions or ideas.

    Please give it a try!


    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team

  • 2.  RE: Getting Started using Python In MapInfo Pro

    Posted 11-17-2020 23:32
    Hi Bob.

    Quick question, does MapInfo use the 3.7 version only?
    I'm asking as I already had 3.8 installed on my machine, and now I'm not sure if any of the samples are running correctly.

    Do I need to have all the libs in 3.7 folder? or is there a way for MapInfo to recognize the current version installed and subsequent Libs ?

    Maria Sousa
    Bella Vista NSW

  • 3.  RE: Getting Started using Python In MapInfo Pro

    Posted 11-18-2020 10:27
    Hi Maria,

    Yes Pro uses and requires Python 3.7. We install everything that is needed along with many Python modules.

    Here is some info from 2019.1 release notes. I hope it is not too much information :-) but feel free to ask any followup questions.



    Starting from version 2019.1 MapInfo Pro x64 and MapInfo Runtime x64 Python 3.7.6 x64 will be installed with product in installation directory under Python37 folder. 

    Pro uses the PythonNet implementation to interact with the Python environment and allow interop between .net and python.

    Python installation bundled within the product will have the below modules pre-loaded.

    1. numpy
    2. scipy
    3. seaborn
    4. pandas
    5. matplotlib
    6. osgeo (Access to GDAL library with MapInfo EFAL driver for NativeX format)
    7. ptvsd (Python Tools for Visual Studio debug server)
    8. mi_py_debugger (Custom module enable debugging of python script in MapInfo Pro)
    9. PyQT5
    10. PyWin32

    Python and the modules are installed in a subfolder under the Pro installation folder named PYTHON37

    EFAL is installed in a subfolder under the Pro installation folder named EFAL

    Install Additional Python modules:

    To install additional python modules user need to open the script prompt.bat in %INSTALLDIR%\Python37 folder and then execute the below command.

    python -m pip install <module_name>

    Python Environment Variables and Initialization (Internal only)

    During the initialization of Python within MapInfo Pro, below environment variables are defined in the executing MapInfo Pro process for correctly loading shipped python37.

    PROHOME → Path to current executing MapInfo Pro executable.

    PROPYTHONHOME → Path to %INSTALLDIR%\Python37 folder shipped with MapInfo Pro installation.

    PATH → Below paths added to PATH environment variable.

    • Path to %INSTALLDIR%\Python37 folder shipped with MapInfo Pro installation.
    • Path to %INSTALLDIR%\Python37\Scripts folder shipped with MapInfo Pro installation.
    • Path to %INSTALLDIR%\EFAL folder shipped with MapInfo Pro installation.

    Running Python Scripts and Add-ins in MapInfo Pro

    The "run application" MapBasic statement now supports running *.py files. Any valid python will work as long as the required modules are installed.

    The Run Program dialog (Ctrl+U) now list both .mbx and .py files.

    In addition you can drag a .py file onto Pro to run it.

    If a file is found in one of the following locations it is executed in the global scope setup. Similar to the way startup.wor is found.


    MapInfoPro.exe location

    See GetFolderPath$() MapBasic function for more help on these locations.

    Once the global scope has been initialized as above, each time python code is run a copy of the global scope is made and used to execute the code.

    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team

  • 4.  RE: Getting Started using Python In MapInfo Pro

    Posted 09-26-2023 09:25

    Hi Bob,

    I've been trying to install new packages via the above method but I get the following error:

    C:\Program Files\MapInfo21\Python37>pip install xlrd
    Fatal error in launcher: Unable to create process using '"D:\work\builds\8453219c5662fbb\3RDPARTY\Python37\python.exe"  "C:\Program Files\MapInfo21\Python37\Scripts\pip.exe" install xlrd': The system cannot find the file specified.

    There is no D: drive on my organisation's internal network so I'm not sure where the path is coming from. Can you assist?

    Romano Agostini
    Knowledge Community Shared Account