Skip to content
⚡ Developer documentation for INFINICAM, the real-time high-speed camera (UC-1.1 / GbE-2)

Setting up a Python development environment

This page walks you step by step, even if you are new to programming, through to running a program that controls INFINICAM from Python.

To use INFINICAM from Python, you use a dedicated library called pypuclib. pypuclib includes the SDK components (DLLs), so unlike C++, you don’t need to set up the SDK separately or install Visual Studio.

Follow the steps from top to bottom, and at the end you will have a program that connects to the camera. If something doesn’t work along the way, see Troubleshooting.

Step What you do Time
1 Install Python 10 min
2 Install pypuclib 10 min
3 Check the installation without a camera 5 min
4 Connect to the camera and run a program 10 min

  • A Windows 10 / 11 (64-bit) PC: pypuclib is 64-bit only.
  • Administrator rights: needed for the firewall setting in step 4. If you don’t have them on a university PC, ask your administrator.
  • An internet connection
  • The INFINICAM camera and its cable: used in step 4. You can do everything up to step 3 without a camera.

pypuclib supports Python 3.9 to 3.15. On this page, you install the latest Python 3.15 using the Python install manager provided by the official Python website.

  1. Download the Python install manager

    Open the Python downloads page (python.org) and click “Download Python install manager”. The installer file is downloaded.

    The python.org downloads page, with the Download Python install manager button outlined in red
  2. Install the Python install manager

    Double-click the downloaded file. When the following window opens, leave “Launch when ready” checked and click “Install Python”.

    The Install Python Install Manager? window, with the Install Python button outlined in red
  3. Initial configuration (answer the questions)

    When the installation finishes, a black window (terminal) opens automatically and shows a series of questions. For each one, type y and press Enter.

    1. Allow long paths? (Update setting now? [y/N])

      The message Windows is not configured to allow paths longer than 260 characters, followed by Update setting now? [y/N]

      Answer y. This Windows setting allows file locations (paths) longer than 260 characters. It is needed when installing libraries such as PyTorch that contain files with very long paths. If you see “Do you want to allow this app to make changes to your device?”, choose “Yes”. The setting takes effect after you restart the PC, but you can continue without restarting.

    2. Add the commands folder to PATH? (Add commands directory to your PATH now? [y/N])

      The message The global shortcuts directory is not configured, followed by Add commands directory to your PATH now? [y/N]

      Answer y. This lets you use commands with a version number, such as python3.15.

    3. Install Python itself? (Install CPython now? [Y/n])

      The message You do not have the latest Python runtime, followed by Install CPython now? [Y/n]

      Answer y. The latest Python (3.15) is downloaded and installed.

    When you see Installing Python 3.15.0. with a green check mark, followed by Configuration checks completed., you are done.

    Installing Python 3.15.0. and a green check mark after Extracting, followed by Configuration checks completed.

    Finally you are asked View online help? [y/N] (open the online help). Answer n and close the window.

  4. Check the installation

    Open a new Command Prompt: press Win + R, type cmd, and press Enter. A black window opens.

    Type the following command and press Enter.

    Terminal window
    python -V

    If you see a version starting with Python 3.15., it worked (the last number may be different).

    Python 3.15.0

  1. Download the ZIP file

    Download the pypuclib ZIP file from the Resources & Downloads page.

  2. Extract the ZIP file

    Right-click the downloaded ZIP file and choose “Extract All”.

    When asked where to extract it, type C:\ and click “Extract”. A folder named C:\pypuclib is created.

    If it looks like this, it was extracted correctly.

    • Directorypypuclib/ Folder created directly under C:\
      • Directorywheels/ Installation files (one for each Python version)
        • pypuclib-(version)-cp39-cp39-win_amd64.whl
        • …
        • pypuclib-(version)-cp315-cp315-win_amd64.whl
      • Directorysamples/ Sample programs
        • …
      • verify_install.py Program to check the installation
      • README.md Instructions
  3. Install pypuclib

    In Command Prompt, type and run the following 2 lines, one at a time. The first line moves to the extracted folder and the second installs it.

    Terminal window
    cd C:\pypuclib
    Terminal window
    python -m pip install --no-index --find-links wheels pypuclib

    If it ends with Successfully installed pypuclib-..., it worked (... is the version number).

  4. Install the libraries used by the samples

    The sample programs on this site also use the following 3 libraries for image calculations, display, and saving.

    Library Used for
    NumPy Calculating with images as arrays of numbers
    OpenCV Displaying, saving, and processing images
    Pillow Saving images (used by some samples)

    There are 2 ways to install them. Do one of the two. Both download and install from the internet.

    Method 1 (recommended): use the list file (requirements.txt)

    If you have extracted the sample code bundle (infinicam_projects) from the Resources & Downloads page to C:\, this method is easiest. C:\infinicam_projects\python contains a file named requirements.txt that lists the library names. In Command Prompt, run the following 2 lines, one at a time.

    Terminal window
    cd C:\infinicam_projects\python
    Terminal window
    python -m pip install --only-binary=:all: -r requirements.txt

    -r requirements.txt means “install the libraries listed in this file”.

    Method 2: type the library names

    If you are not using the sample code bundle, or want to choose the libraries yourself, install them by name. In Command Prompt, run this one line.

    Terminal window
    python -m pip install --only-binary=:all: numpy opencv-python pillow
    Part Meaning
    python -m pip install Install with pip (the tool for installing Python libraries)
    --only-binary=:all: Accept only ready-to-use (prebuilt) files (see the warning below)
    numpy opencv-python pillow The names of the libraries to install (separated by spaces)

    With either method, it worked if it ends with Successfully installed .... The latest OpenCV 5 is installed.


3. Checking the installation (without a camera)

Section titled “3. Checking the installation (without a camera)”

Use the checking program in the ZIP, verify_install.py, to make sure everything was installed correctly.

  1. Run the checking program

    In Command Prompt, run the following 2 lines, one at a time (if you are continuing from step 2-3, you can skip the first line).

    Terminal window
    cd C:\pypuclib
    Terminal window
    python verify_install.py
  2. Check the result

    It worked if every line has [OK] and the last line says all checks passed, like this.

    Python
    ------
    [OK] version 3.15.0
    [OK] 64 bit yes
    pypuclib
    --------
    [OK] import pypuclib
    [OK] loaded from C:\Users\...\site-packages\pypuclib.cp315-win_amd64.pyd
    [OK] PUCLIB.dll
    [OK] PUCUTIL.dll
    [OK] ICYUSB.dll
    [OK] IGETHERB.dll
    [OK] PICCLIB.dll
    SDK
    ---
    [OK] initialise the SDK
    [OK] GPU decoding available
    all checks passed

    If a line has no [OK], the reason is shown to the right of that line. See Troubleshooting as well.


Now you create a program that connects to the camera and displays its serial number, resolution, and frame rate.

  1. Allow traffic from the camera through the firewall (GbE-2 only, first time only)

    Windows Firewall blocks python.exe from communicating with the camera. As is, the camera can be found, but connecting to it always fails.

    So you create one rule that allows traffic coming from the camera (192.168.0.10).

    1. Type “PowerShell” in the Start menu, right-click PowerShell in the results, and choose “Run as administrator”.

    2. Copy and paste the following line and press Enter.

      Terminal window
      New-NetFirewallRule -DisplayName "INFINICAM GbE-2" -Direction Inbound -Protocol UDP -RemoteAddress 192.168.0.10 -Action Allow -Profile Any
    3. When you see DisplayName : INFINICAM GbE-2 and Enabled : True, you are done.

  2. Check the camera with the checking program

    Turn on the camera, connect it to the PC, and run the following 2 lines, one at a time, in Command Prompt.

    Terminal window
    cd C:\pypuclib
    Terminal window
    python verify_install.py --camera

    It worked if, following the output from step 3, you see a Camera section like this and all checks passed at the end (the resolution and frame rate depend on the camera’s settings).

    Camera
    ------
    [OK] network adapters 127.0.0.1, 192.168.0.1
    [OK] cameras found (deviceNo=None,deviceType=1,ipAddress=192.168.0.10)
    [OK] open the camera
    [OK] resolution 800x600
    [OK] sensor monochrome
    [OK] framerate 1000 fps (up to 1054 at this resolution)
    [OK] grab and decode (600, 800) uint8
    all checks passed
  3. Prepare a folder for your programs

    In File Explorer, open C:\infinicam_projects and create a folder named python inside it (create C:\infinicam_projects first if it doesn’t exist). The explanations on this site assume all Python programs are saved here.

    If you have extracted the sample code bundle to C:\, this folder already exists. Go on to the next step.

  4. Enter and save the program

    Open Notepad, then copy and paste the following code.

    from pypuclib import CameraFactory, PUCException
    print("Connecting to the camera...")
    try:
    # Connect to the GbE-2 at this IP address
    cam = CameraFactory().create(ip="192.168.0.10")
    except PUCException as e:
    print("Error: could not connect to the camera.", e)
    raise SystemExit(1)
    print("Connected.")
    print("Serial number:", cam.serialNo())
    reso = cam.resolution()
    print("Resolution:", reso.width, "x", reso.height)
    print("Frame rate:", cam.framerate(), "fps")
    # Close the camera when you are done with it
    cam.close()
    print("Done.")

    Choose File > Save As from the menu, set the following, and click Save.

    Item Value
    Location C:\infinicam_projects\python
    File name hello_camera.py
    Save as type All files (*.*)
    Encoding UTF-8
  5. Connect the camera and run it

    In Command Prompt, run the following 2 lines, one at a time.

    Terminal window
    cd C:\infinicam_projects\python
    Terminal window
    python hello_camera.py

    If you see output like the following, it worked (the serial number and frame rate depend on your camera).

    Connecting to the camera...
    Connected.
    Serial number: 99334002087
    Resolution: 800 x 600
    Frame rate: 1000 fps
    Done.

    You are now ready to control INFINICAM from Python.


Symptom / error Likely cause What to do
Double-clicking the downloaded file does nothing, or installation is blocked Installing Store-style (.msix) apps is restricted on a university or company PC On Python Releases for Windows, download and run “Download MSI package” under “Python install manager”. If that still doesn’t install, ask your PC administrator
You closed the black window before answering the questions — Run py install --configure in Command Prompt to see the same questions again
Typing python opens the Microsoft Store The Python install manager is not installed Redo steps 1-1 to 1-3. Open a new Command Prompt after installing
'python' is not recognized as an internal or external command... Same as above, or you are using a Command Prompt that was open before the installation Open a new Command Prompt. If that doesn’t fix it, redo steps 1-1 to 1-3
python -V shows an older version such as Python 3.14.x Python installed another way earlier is still there and is found first In Settings > Apps > Installed apps, uninstall the old Python 3.x.x (64-bit) and Python Launcher, then open a new Command Prompt
ERROR: No matching distribution found for pypuclib The wheels folder has no file for your Python (an unsupported Python version, or 32-bit Python) Check the version with python -V and use 64-bit Python 3.9 to 3.15
ERROR: ... does not exist / “file not found” You have not moved to C:\pypuclib, or it was extracted somewhere else Run cd C:\pypuclib and try again. Check that the folder is not nested twice (step 2-2)
ImportError: DLL load failed while importing pypuclib The Visual C++ Redistributable is not installed Install vc_redist.x64.exe
PUC_Initialize:13 couldn't load sdk modules. Some pypuclib DLLs are missing Move to C:\pypuclib and reinstall with python -m pip install --force-reinstall --no-index --find-links wheels pypuclib
ModuleNotFoundError: No module named 'cv2' (or numpy) The libraries from step 2-4 are not installed Do step 2-4
An error with an unfamiliar name, such as No matching distribution found for numphy A library name was mistyped Copy and paste the step 2-4 command again. With Method 1 (requirements.txt), you don’t need to type names
Error: could not connect to the camera. couldn't find any camera Camera power, cable, or IP address settings Check PC requirements and network settings. Check that the IP address in the program matches the camera
The camera is found but cannot be opened (the error contains PUC_OpenDevice2:9) Blocked by Windows Firewall, or another application is using the camera Create the rule in step 4-1. Close other applications such as viewers (a camera can be used by only one application at a time)
IndentationError / SyntaxError The indentation is off, or part of the code is missing Copy and paste the code again
No such file or directory when running python hello_camera.py Saved in the wrong place, or saved as hello_camera.py.txt Open C:\infinicam_projects\python in File Explorer and check the file name (step 4-4)

When reporting a problem, please include the output of python verify_install.py --camera. It helps us investigate faster.


Used with permission from Microsoft.