I have a project I'm trying to test and run on Jenkins. On my machine it works fine, but when I try to run it in Jenkins, it fails to find a module in the workspace.
In the main workspace directory, I run the command:
python xtests/app_verify_auto.py
And get the error:
+ python /home/tomcat7/.jenkins/jobs/exit103/workspace/xtests/app_verify_auto.py
Traceback (most recent call last):
File "/home/tomcat7/.jenkins/jobs/exit103/workspace/xtests/app_verify_auto.py", line 19, in <module>
import exit103.data.db as db
ImportError: No module named exit103.data.db
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The directory exit103/data exists in the workspace and is a correct path, but python can't seem to find it.
This error exists both with and without virtualenv.
It's may caused by your PATH setting not right in jenkins environment.In fact , the environments for your default user and jenkins-user are not the same.
You may try to find what are the PATH and PYTHONPATH in your jenkins-user environments .
Try to run "shell commands" in jenkins "echo $path" and so on to see what's them are.
In most of time , you need to set the PATH by yourself.
You may reference this answer.
Jenkins: putting my Python module on the PYTHONPATH
Faced the same issue.
For others who are reading this, Run the build in your master node. It fixed the problem for me.
Running the build in the slave node doesn't give proper access to all the python modules and other commands such as jq to the workspace.
Related
When I try to run a script in conda environment it gives me a ModuleNotFound error
(ldm) C:\Users\Иван\Documents\git\stable-diffusion>python scripts/txt2img.py --prompt "a photograph of an astronaut in space" --plms
Traceback (most recent call last):
File "scripts/txt2img.py", line 17, in <module>
from ldm.util import instantiate_from_config
ModuleNotFoundError: No module named 'ldm'
Here are the txt2img.py's lines causing the trouble
from ldm.util import instantiate_from_config
from ldm.models.diffusion.ddim import DDIMSampler
from ldm.models.diffusion.plms import PLMSSampler
But the main points are:
There is a folder called "ldm" containing everything needed
There are no complains from the compiler in the actual code editor
What I'm sure of:
The txt2img.py's directory is C:\Users\Иван\Documents\git\stable-diffusion\scripts\txt2img.py and the ldm's directory is C:\Users\Иван\Documents\git\stable-diffusion\ldm
Anaconda is added to my PATH environment variable
I'm trying to make it work in VSCode terminal (I set it up to run conda) but it's absolutely the same in the separate Anaconda Prompt
The problem does not occur with other projects
Is there a way to fix this?
The problem got resolved with typing in the following:
pip install -e .
I think it just installs all the packages from the project folder
As a quick solution try the following:
cd C:\Users\Иван\Documents\git\stable-diffusion
C:\Users\Иван\Documents\git\stable-diffusion> python scripts\txt2img.py --prompt "a photograph of an astronaut in space" --plms
In VSCode, do the following:
Add 'C:\Users\Иван\Documents\git\stable-diffusion' to your workspace
Open VSCode Terminal (ctrl + ~)
Follow the steps from here
Run your script
python scripts\txt2img.py --prompt "a photograph of an astronaut in space" --plms
Update based on comment:
You need to add an empty __init__.py inside all your folders. Refer here
I think I'm missing something obvious here. I cloned this repo, and now have this directory structure on my computer:
When I try to run python baby_cry_detection/pc_main/train_set.py, I get a ModuleNotFoundError.
Traceback (most recent call last):
File "baby_cry_detection/pc_main/train_set.py", line 10, in <module>
from baby_cry_detection.pc_methods import Reader
ModuleNotFoundError: No module named 'baby_cry_detection'
However, if I type python and enter the interactive shell and then type the command
from baby_cry_detection.pc_methods import Reader
it imports just fine with no error. I'm completely baffled. I'm using a virtualenv and both instances are using the same python installation, and I haven't changed directories at all.
I think sys.path could be the reason that the module is not found when python command is executed. Here is how we can check if that is indeed the case:
In the train_set.py file, add import sys; print(sys.path). Looking at the error, the path may contain /path/to/baby_cry_detection/baby_cry_detection/pc_main. If that is the case, then we have found the issue which is that baby_cry_detection.pc_methods will not be found in the directory that sys.path is looking into. We'll need to append the parent baby_cry_detection directory to sys.path or use relative imports. See this answer.
The reason that python prompt successfully imports the module could be because the prompt is started in the correct parent directory. Try changing the directory to baby_cry_detection/pc_main/ and try importing the module.
I am trying to use Openpose from windows and i need to run .py file. But i couldn't find any command to install pyopenpose module So where can I find pyopenpose module?
I tried this command on cmd:
C:\openpose\examples\tutorial_api_python>python 01_body_from_image.py
I get the error :
Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?
Traceback (most recent call last):
File "01_body_from_image.py", line 26, in <module>
raise e
File "01_body_from_image.py", line 17, in <module>
import pyopenpose as op
ModuleNotFoundError: No module named 'pyopenpose'
The error in general is that PyOpenPose cannot be found (an error similar to: ImportError: cannot import name pyopenpose). Ensure first that BUILD_PYTHON flag is set to ON. If the error persists, check the following:
In the script you are running, check for the following line, and run the following command in the same location as where the file is.
Ubuntu/OSX:
sys.path.append('../../python');
ls ../../python/openpose
Check the contents of this location. It should contain one of the following files:
pyopenpose.cpython-35m-x86_64-linux-gnu.so
pyopenpose.so
If you do not have any one of those, you may not have compiled openpose successfully, or you may be running the examples, not from the build folder but the source folder. If you have the first one, you have compiled PyOpenPose for Python 3, and have to run the scripts with python3, and vice versa for the 2nd one. Follow the testing examples above for exact commands.
Windows:
Problem 1: If you are in Windows, and you fail to install the required third party Python libraries, it might print an error similar to: Exception: Error: OpenPose library could not be found. Did you enable BUILD_PYTHON in CMake and have this Python script in the right folder?. From GitHub issue #941:
I had a similar issue with Visual Studio (VS). I am pretty sure that the issue is that while you are compiling OpenPose in VS, it tries to import cv2 (python-opencv) and it fails. So make sure that if you open cmd.exe and run Python, you can actually import cv2 without errors. I could not, but I had cv2 installed in a IPython environment (Anaconda), so I activated that environment, and then ran (change this to adapt it to your VS version and location of OpenPose.sln):
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild.exe
C:\path\to\OpenPose.sln
Problem 2: Python for Openpose needs to be compiled in Release mode for now. This can be done in Visual Studio. Once that is done check this line:
sys.path.append(dir_path + '/../../python/openpose/Release');
dir ../../python/openpose/Release
Check the contents of this location. It should contain one of the following files:
pyopenpose.cp36-win_amd64.pyd
pyopenpose.pyd
If such a folder does not exist, you need to compile in Release mode as seen above. If you have the first one, you have compiled PyOpenPose for Python 3, and have to run the scripts with python3, and vice versa for the 2nd one. Follow the testing examples above for exact commands. If that still does not work, check this line:
os.environ['PATH'] = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' + dir_path + '/../../bin;'
dir ../../x64/Release
dir ../../bin
Ensure that both of these paths exist, as PyOpenPose needs to reference those libraries. If they don't exist, change the path so that they point to the correct location in your build folder.
I trying to build the ungoogled chrome source from github. I was following the instructions in the link below, but I really do not know how to continue.
I installed python 2.7 and 3.7, set them in the PATH.
Used the git clone command and jumped the replace comands and the git checkout too, because I didin't got them.
So, I tried the "py build.py" command and got this error.
C:\Users\aquasp\ungoogled-chromium-windows>py build.py
Traceback (most recent call last):
File "build.py", line 24, in <module>
import buildkit.config
ModuleNotFoundError: No module named 'buildkit'
Is there any suggestions?
This are the commands that I was folowing:
git clone --recurse-submodules https://github.com/ungoogled-software/ungoogled-chromium-windows.git
# Replace TAG_OR_BRANCH_HERE with a tag or branch name
git checkout --recurse-submodules TAG_OR_BRANCH_HERE
py build.py
py package.py
https://github.com/ungoogled-software/ungoogled-chromium-windows
I'm assuming you are on a windows machine. Try running the dos 'which' command with an argument of 'buildkit' as follows:
which buildkit
The output will be the search of directories in the path variable of the windows machine as follows:
which: no buildkit in (/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1
etc...
'buildkit' is not found on path or the python.exe is not on the path.
Try 'which python' or 'which py' to test for python.exe or py in the machine path.
if python.exe is found output is as follows:
/c/Program Files/python/python
or if not found
which: no python found in (/c/WINDOWS/system32: etc...
Last but not least, add buildkit or python.exe or py to your machines path variable as follows:
set path=%path%;plus\new\path
C:\Users>echo %path%
C:\WINDOWS\system32;plus\new\path
I have a problem with using the rqt_image_view package in ROS. Each time when I type rqt_image_view or rosrun rqt_image_view rqt_image_view in terminal, it will return:
Traceback (most recent call last):
File "/opt/ros/kinetic/bin/rqt_image_view", line 16, in
plugin_argument_provider=add_arguments))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_gui/main.py", line 59, in main
return super(Main, self).main(argv, standalone=standalone, plugin_argument_provider=plugin_argument_provider, plugin_manager_settings_prefix=str(hash(os.environ['ROS_PACKAGE_PATH'])))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/qt_gui/main.py", line 338, in main
from python_qt_binding import QT_BINDING
ImportError: cannot import name QT_BINDING
In the /.bashrc file, I have source :
source /opt/ros/kinetic/setup.bash
source /home/kelu/Dropbox/GET_Lab/leap_ws/devel/setup.bash --extend
source /eda/gazebo/setup.bash --extend
They are the default path of ROS, my own working space, the robot simulator of our university. I must use all of them. I have already finished many projects with this environmental variable setting. However, when I want to use the package rqt_image_view today, it returns the above error info.
When I run echo $ROS_PACKAGE_PATH, I get the return:
/eda/gazebo/ros/kinetic/share:/home/kelu/Dropbox/GET_Lab/leap_ws/src:/opt/ros/kinetic/share
And echo $PATH
/usr/local/cuda/bin:/opt/ros/kinetic/bin:/usr/local/cuda/bin:/usr/local/cuda/bin:/home/kelu/bin:/home/kelu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Then I only source the /opt/ros/kinetic/setup.bash ,the rqt_image_view package runs!!
It seems that, if I want to use rqt_image_view, then I can not source both /opt/ros/kinetic/setup.bash and /home/kelu/Dropbox/GET_Lab/leap_ws/devel/setup.bash at the same time.
Could someone tell me how to fix this problem? I have already search 5 hours in google and haven't find a solution.
Different solutions to try:
It sounds like the first path /eda/gazebo/ros/kinetic/share or /home/kelu/Dropbox/GET_Lab/leap_ws/src has an rqt_image_view package that is being used. Try to remove that dependency.
Have you tried switching the source files being sourced? This depends on how the rqt_image_view package was built, such as by source or through a package manager.
Initially, it sounds like there is a problem with the paths being searched or wrong package being run since the package works with the default ROS environment setup.