Python FAQ

  1. I get the following error when Gatan Microscopy Suite® (GMS) software starts up, what should I do?

    Answer: Most likely, when you upgraded GMS software from 3.4.0 to 3.4.1 or higher, you did not uninstall and reinstall Miniconda.GMS 3.4.0 uses an MKL-based NumPy installation.GMS 3.4.1 (and higher) requires an OpenBLAS-based NumPy library instead.

    To solve this problem, reinstall the GMS virtual environment using GMS or higher. Any version of GMS before 3.4.1. 2984 requires you to uninstall Miniconda before reinstalling GMS with Python support.

  2. How do I check what Python/NumPy version is used in GMS?

    Answer: On startup, you can go to the Result window / Debug.

  3. Which Python package manager should I use to install libraries on GMS Python Virtual environment?

    Answer: In general, we recommend using pip install instead of conda install. GMS uses OpenBLAS-based (NumPy) libraries, and conda install tends to install MKL-based libraries.

  4. I got this error when running a subsequent python script after using Scipy library in the first Python script, what should I do to solve this?

    Answer: Some Python libraries (such as Scipy, require the script to be run in the main thread. Running a script (that requires it to be run in the main thread) in the background thread will cause the script to hang in the GMS-embedded Python. To solve this, first, try to use Ctrl + Shift + Q to try to kill the script that is running in the background. If this is not successful, you may need to restart GMS. To run these scripts intentionally, please uncheck the checkbox Execute on Background Thread option in the bottom right Python script window the next time you run the script.

  5. Where is Miniconda installation, and where is GMS Python virtual environment installation?

    Answer: The global (Miniconda) python is installed under C:\ProgramData\Miniconda3\.
    GMS Python virtual environment is installed under C:\ProgramData\Miniconda3\envs\GMS_VENV_PYTHON.

  6. Can we run Python scripts in an external Python environment and call GMS for the internal functions?

    Answer: GMS-Python API is dependent on the GMS application; therefore, it is not possible to execute GMS functions from python outside of the GMS application.

  7. Why does GMS use Miniconda and not Anaconda?

    Answer: We chose Miniconda as a starter since it is a small package, does not take long to install, and it gives users the option to expand it when needed by using the pip install commands.

  8. Can I use some other Python software (not Miniconda)?

    Answer: Yes, however, you do need to be careful about the versions that you are using. You should make sure you are using Python version 3.7.2 and NumPy version 1.18.2. Minor changes to Python (e.g., 3.7.x) and NumPy (e.g., 1.18.x) should also work but can’t be guaranteed. The default python used is Miniconda’s GMS Python Virtual environment (GMS_VENV_PYTHON). You can change to use some other Python software in the Global Info dialog (File / Global Info) and restart GMS.

  9. Can I use my own (user-created) Python virtual environment with GMS?

    Answer: No, a user-created Python virtual environment is not supported, and it will not appear in the Global Info dialog / General / Scripting / Python version drop-down selection for users to select.

  10. How do I find out if OpenBLAS or MKL-based NumPy is installed in the GMS virtual environment?


    (The example shown here is an OpenBLAS based NumPy installation.)

    Launch Anaconda in administrator mode
    Activate GMS_VENV_PYTHON virtual environment :
    (base) C:\WINDOWS\system32>activate GMS_VENV_PYTHON
    Start python interpreter:
    (GMS_VENV_PYTHON) C:\WINDOWS\system32>python
    Python 3.7.2 (default, Feb 21 2019, 17:35:59) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy as np
    >>> numpy.showConfig()
        library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas_info']
        libraries = ['openblas_info']
        language = f77
        define_macros = [('HAVE_CBLAS', None)]
        library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas_info']
        libraries = ['openblas_info']
        language = f77
        define_macros = [('HAVE_CBLAS', None)]
        library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas_lapack_info']
        libraries = ['openblas_lapack_info']
        language = f77
        define_macros = [('HAVE_CBLAS', None)]
        library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas_lapack_info']
        libraries = ['openblas_lapack_info']
        language = f77
        define_macros = [('HAVE_CBLAS', None)]
  11. If I am using MKL-based libraries, how do I change to use OpenBLAS-based libraries for all packages (from Anaconda GMS_VENV_PYTHON prompt):

    (GMS_VENV_PYTHON) C:\WINDOWS\system32>conda install conda-forge::blas=*=openblas

    After invoking the above command, invoke “pip install XXX” where XXX is a python library.

  12. How do I use the MKL-based library for NumPy?

    Answer: You really shouldn’t, MKL-based libraries are not supported at this time. However, if you insist, you can use the following command.

    (GMS_VENV_PYTHON) C:\WINDOWS\system32>conda install numpy

    The conda package manager will update all other affected packages to use MKL-based packages.

    Note the MKL-based NumPy is not supported, and we have observed problems when invoking FFT related functions.

  13. How do I verify the conda environment is installed correctly via conda info or conda list?

    Answer: The conda list will list out all packages info that are installed in the conda environment. There should not be errors in either of these commands.

    (GMS_VENV_PYTHON) C:\WINDOWS\system32>conda info

         active environment : GMS_VENV_PYTHON
        active env location : C:\ProgramData\Miniconda3\envs\GMS_VENV_PYTHON
                shell level : 2
           user config file : C:\Users\wlei\.condarc
     populated config files :
              conda version : 4.8.3
        conda-build version : not installed
             python version :
           virtual packages : __cuda=9.2
           base environment : C:\ProgramData\Miniconda3  (writable)
               channel URLs :
              package cache : C:\ProgramData\Miniconda3\pkgs
           envs directories : C:\ProgramData\Miniconda3\envs
                   platform : win-64
                 user-agent : conda/4.8.3 requests/2.21.0 CPython/3.7.1 Windows/10 Windows/10.0.18362
              administrator : True
                 netrc file : None
               offline mode : False

    (GMS_VENV_PYTHON) C:\WINDOWS\system32>conda list

    # packages in environment at C:\ProgramData\Miniconda3\envs\GMS_VENV_PYTHON:
    # Name                  Version                   Build Channel
    _tflow_select          2.2.0                       eigen
    absl-py                   0.9.0                       py37_0
    asn1crypto             1.3.0                       py37_0
    astor                       0.8.1                       pypi_0    pypi
    blas                         1.0                         mkl
  14. I am using GMS 3.4.1. I am having some trouble installing Tensorflow 2.10. Is it supported by GMS 3.4.1?

    Answer: Yes, it is supported. You will need to install all the pre-requisites before pip install tensorflow command:

    The pre-requisites are:

    CUDA Toolkit 10.2 version:

    Visual Studio 2015-2019 x86 and x64 redistributable:

    Use pip install tensorflow to install the latest tensorflow (currently 2.10). 

    Sometimes, the user may see an error with the wrong h5py version, use pip uninstall h5py, and pip install h5py to install the required version.

  15. When I try to use Ctrl + Shift + Q to kill a running script, I got the following error. What should I do?

    Answer: Some operation in your script is holding onto the Python Global Interpreter Lock and not releasing it, preventing Ctrl Shift Q from terminating the script. If Ctrl + Shift + Q does not work, then you may need to restart GMS.