S
S
slepowl2021-06-29 14:57:34
Python
slepowl, 2021-06-29 14:57:34

When running python scripts in jenkins, libraries from site-packages are not imported. How to solve the problem?

UPD: I solved the issue head-on - with symbolic links. but it's kind of like that.
I will ask to the heap: what to look / read to configure python builds (autotests) with jenkins? What is the true way?
OS: Ubuntu server 20.04
jenkins fresh.
python 3.8.5
The python script that runs in job uses the parmiko module.
pip put this package in /home/root/.local/lib/python3.8/site-packages (pip --target doesn't work for some reason)
job crashes due to

import paramiko
ModuleNotFoundError: No module named 'paramiko'
Build step 'Execute shell' marked build as failure


from under the admin do print (sys.path)
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/root/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']

Accordingly import works.
Do print(sys.path) in job jenkins:
['/home/root/my_tests', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']

jenkins account is included in the testers group, this group has rights to site-packages and nested: drwxrwxr-x 3 root testers 4096 Jun 29 06:40 paramiko

how to make jenkins friends with python?
PS I'm just learning jenkins, don't kick me too hard =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2021-06-29
@vitaly_il1

It's best to use a virtual environment so you don't have to depend on the installation on the host.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question