I have been working with Robot Framework for a short time.
In Python, I installed two additional packages: pyvisa and pyserial.
These are located in the directory: C:\Program Files (x86)\Python39-32\Scripts.
This directory is assigned to the environment variable (system variable) “Path”.
Now I want to use (import) these two packages in Robot Framework.
I have created a Robotor: Basic Python Template.
At the beginning of the file task.py I import all the python-packages I need such as
import os
import sys
import serial
import pyvisa
…
When I run my Robot, the message "No module named serial" or "No module named pyvisa" appears.
Thank you for your answer. In my example I am using a pure Python robot task.py (Basic Python Template) - not an A.robot.
In the test case I am trying to connect to an external device using a Modbus communication over a COM port.
In my planned test case several Python scripts have to be imported. But that’s not really the problem. Because it’s about importing installed Python packages.
I show a very simple, modified Python script in which I include the Python packages. You can already see from the Python code that
the Robot Framework does not recognize the two Python packages “serial” and “pyvisa” - see line 6 and 7.
thank you for your answer. I have a question. Could it be that the problem lies both with using the Python interpreter and with accessing the environment variables.
When I write a Python script and run it in VSCode (not in Robot framework),
the Python interpreter assigned to the “Path” system variable is used: C:\Program Files (x86)\Python39-32.
On the other hand, if I start a Python script in Robot-Framework, then Robot-Framework uses a Python interpreter from the directory: C:\ProgramData\robocorp\ht.
The same is with the environment variables. A normal Python script, which is not executed in the Robot Framework, accesses the directory
C:\Program Files (x86)\Python39-32\Scripts, which is also mapped to the “Path” environment variable.
The situation is different in the Robot Framework. Here folders are accessed which are located in the directory C:\ProgramData\robocorp\ht\ for example
C:\ProgramData\robocorp\ht\368d3ba_b1f3c24_d4ec2478\Scripts.
Here my question: Is it possible to change the Python interpreter as well as the access to the environment variables in Robot Framework?
I would like Robot Framework to use the interpreter from C:\Program Files (x86)\Python39-32\ and the environment variable Path with
C:\Program Files (x86)\Python39-32\Scripts.