I am following this tutorial using Google Colab.
When I run the line game.init(), I get this error:
ViZDoomErrorException: Could not initialize SDL video:
No available video device
I installed vizdoom as follows:
%%bash
# Install deps from
# https://github.com/mwydmuch/ViZDoom/blob/master/doc/Building.md#-linux
apt-get install build-essential zlib1g-dev libsdl2-dev libjpeg-dev \
nasm tar libbz2-dev libgtk2.0-dev cmake git libfluidsynth-dev libgme-dev \
libopenal-dev timidity libwildmidi-dev unzip
# Boost libraries
apt-get install libboost-all-dev
# Lua binding dependencies
apt-get install liblua5.1-dev
Colab is run on a machine in the cloud. It cannot send the display back to your local machine. That's why it said "no video device".
Add the line game.set_window_visible(False) in the Step 8 cell of the Jupyter Notebook. Unless explicitly mentioned, ViZDoom tries to launch the application, which is not supported in Colab.
Related
I want the exact version of Python 3.8.13 to run on my container, but so far when I used the below, it generated a very large Docker image:
RUN yum update -y && yum install -y python3.8 python38-pip && yum clean all
The command "yum install python3.8" installs 3.8.13 and this is fine, but as mentioned, the end result (with other required elements) is a bit above 2 GB once built. I would like to make the image smaller and I am wondering if I can use a slim or alpine version of Python 3.8.13.
I was trying with the following commands:
yum install -y python3.8.13-slim
yum install -y python3.8.13-slim-buster
yum install -y python3.8-slim
Did not succeed, yum does not recognize these as valid packages.
Is there a workaround for this?
I'm a beginner into python language. I want to develop an android app. I've wrote some code and few days ago I wanted to see how my app looks on mobile before continue.
I've tried all methods to convert .py to .apk but failed. I've tried with google colab, I've installed a VM... but nothing worked. If I use google colab, after all I receive an .apk, but when I install it on my phone, doesn't work... The app opens, but closes imediatly.
If I use VM I receive this error: error message
This is a picture of all my components: components
For google colab I'm using this commands :
!pip install buildozer
!pip install cython==0.29.19
!sudo apt-get install -y
python3-pip
build-essential
git
python3
python3-dev
ffmpeg
libsdl2-dev
libsdl2-image-dev
libsdl2-mixer-dev
libsdl2-ttf-dev
libportmidi-dev
libswscale-dev
libavformat-dev
libavcodec-dev
zlib1g-dev
!sudo apt-get install -y
libgstreamer1.0
gstreamer1.0-plugins-base
gstreamer1.0-plugins-good
!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6
!sudo apt-get install libffi-dev
!buildozer init
!buildozer -v android debug
!buildozer android clean
This is a picture with my google colab: google colab & buildozer.spec
I've tried all tutorials I've found on internet but nothing worked.
The code works perfectly on PC!
Please, help me!
You could try pydroid 3... This isn't really a solution but for now, if you are trying to see how your app looks on an Android device. Get Pydroid 3 from play store. Create a new file and copy your code across into the app and run it... It will run kivy but not kivymd....
If your getting the apk from colab it might be a problem in the code, trying it on pyroid my highlight something and if so when that's altered the new APK might work
Can you connect phone to your system and run this command
adb logcat -s python and then open the app in mobile. This will give you a log why your app crashed. I suspect some issue with the requirements in buildozer.
Could you run the command and share the log?
I think you should see this solution
You can use this video to test that solution (It's in Spanish but I hope you can translate it)
I tried and it works
The key is to edit buildozer.spec
After that you can test your own solution
I am try to implement Qt-Virtualkeyboard in Raspberry- pi, using PyQt5 - Show virtual keyboard but I did'nt find the prefix path for it, bin, plugin etc folder, actually whole Qt folder doesn't exist.
In my previous solution I used the Qt binaries officially provided but not compatible with the RPI architecture so you have to compile it:
sudo apt-get update
sudo apt install git build-essential
sudo apt-get install python3-pyqt5 qt5-default qtdeclarative5-dev libqt5svg5-dev qtbase5-private-dev qml-module-qtquick-controls2 qml-module-qtquick-controls qml-module-qt-labs-folderlistmodel
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
git clone -b 5.11 https://github.com/qt/qtvirtualkeyboard.git
cd qtvirtualkeyboard
qmake
sudo make
sudo make install
Installing grpcio-reflection with pip takes a really long time.
It is strange because the pip package is only 8KB in PyPI but downloading takes more than a minute while other packages that are in the megabytes are downloaded really fast.
UPDATE:
It was not downloading, there is a lot of compilation going on. It seems to be that the feature is still in alpha so the package is not precompiled like standard grpcio
UPDATE2: Repro steps
I have just opened an issue here: https://github.com/grpc/grpc/issues/12992 and I am copying the repro steps here for completion.
It seems that grpci-reflection package installation freezes depending on other packages in the same command line
This can be easily reproduced by these two docker different containers:
Dockerfile.fast - Container creation time ~1m 23s
#Download base ubuntu image
FROM ubuntu:16.04
RUN apt-get update && \
apt-get -y install ca-certificates curl
# Prepare pip
RUN apt-get -y install python-pip
RUN pip install -U pip
RUN pip install grpcio grpcio-tools
RUN pip install grpcio-reflection # Two lines is FAST
Dockerfile.slow - Container creation time 5m 20s
#Download base ubuntu image
FROM ubuntu:16.04
RUN apt-get update && \
apt-get -y install ca-certificates curl
# Prepare pip
RUN apt-get -y install python-pip
RUN pip install -U pip
RUN pip install grpcio grpcio-tools grpcio-reflection # Single line is SLOW
Timing containers build time:
time docker build --rm --no-cache -f Dockerfile.fast -t repro_reflbug_fast:latest .
......
real 1m22.295s
user 0m0.060s
sys 0m0.040s
time docker build --rm --no-cache -f Dockerfile.slow -t repro_reflbug_slow:latest .
.....
real 6m28.290s
user 0m0.052s
sys 0m0.052s
.....
I didn't have time yet to investigate but the second case blocks for a long time while the first one doesnt.
It turns out that this issue was accepted as valid in the corresponding GitHub repo. It is now being discussed here:
https://github.com/grpc/grpc/issues/12992
The opencv works fine when doing other things. It can open images and show images. But it can't open a video.
The code I'm using to open a video is as below
import cv2
cap = cv2.VideoCapture("MOV_0006.mp4")
while True:
ret, frame = cap.read()
cv2.imshow('video', frame)
if cv2.waitKey(1) & 0xff == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
But when executing, it outputs error messages like below
[h264 # 0x1053ba0] AVC: nal size 554779904
[h264 # 0x1053ba0] AVC: nal size 554779904
[h264 # 0x1053ba0] no frame!
My vlc and mplayer can play this video, but the opencv can't.
I have installed x264 and libx264-142 codec package. (using sudo apt-get install)
My version of ubuntu is 14.04 trusty.
I'm not sure is it a codec problem or not?
I have rebuilt opencv either with WITH_UNICAP=ON or with WITH_UNICAP=OFF, but it doesn't affect the problem at all. The error messages never change.
It's a codec problem
I converted that mp4 file to an avi file with ffmpeg. Then the above opencv code can play that avi file well.
Therefore I am sure that this is a codec problem.
(I then converted that mp4 file to another mp4 file using ffmpeg, thinking maybe ffmpeg would help turning that original unreadable .mp4 codec into a readable .mp4 codec, but the resulting .mp4 file ended up broken. This fact may or may not relate to this problem, just mentioning, in case anybody needs this information.)
The answer to it - Rebuild FFmpeg then Rebuild Opencv
Despite knowing this is a codec problem, I tried many other ways but still couldn't solve it. At last I tried rebuilding ffmpeg and opencv, then the problem was solved!
Following is my detailed rebuilding procedure.
(1) Build ffmpeg
Download ffmpeg-2.7.1.tar.bz2
FFmpeg website: https://www.ffmpeg.org/download.html
ffmpeg-2.7.1.tar.bz2 link: http://ffmpeg.org/releases/ffmpeg-2.7.1.tar.bz2
tar -xvf ffmpeg-2.7.1.tar.bz2
cd ffmpeg-2.7.1
./configure --enable-pic --extra-ldexeflags=-pie
From http://www.ffmpeg.org/platform.html#Advanced-linking-configuration
If you compiled FFmpeg libraries statically and you want to use them to build your own shared library, you may need to force PIC support (with --enable-pic during FFmpeg configure).
If your target platform requires position independent binaries, you should pass the correct linking flag (e.g. -pie) to --extra-ldexeflags.
If you encounter error:
yasm/nasm not found or too old. Use --disable-yasm for a crippled build.
Just sudo apt-get install yasm
Further building options: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
e.g. Adding option --enable-libmp3lame enables png encoder. (Before ./configure you need to sudo apt-get install libmp3lame-dev with version ≥ 3.98.3)
make -j5 (under ffmpeg folder)
sudo make install
(2) Build Opencv
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip opencv-2.4.9.zip
cd opencv-2.4.9
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_QT=OFF -D WITH_V4L=ON -D CMAKE_SHARED_LINKER_FLAGS=-Wl,-Bsymbolic ..
You can change those options depend on your needs. Only the last one -D CMAKE_SHARED_LINKER_FLAGS=-Wl,-Bsymbolic is the key option. If you omit this one then the make will jump out errors.
This is also from http://www.ffmpeg.org/platform.html#Advanced-linking-configuration (the same link of step 4 above)
If you compiled FFmpeg libraries statically and you want to use them to build your own shared library, you may need to ... and add the following option to your project LDFLAGS: -Wl,-Bsymbolic
make -j5
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
Now the opencv code should play a mp4 file well!
Methods I tried but didn't work
Try add WITH_UNICAP=ON WITH_V4L=ON when cmake opencv. But didn't work at all.
Try changing codec inside the python opencv code. But in vain.
cap = cv2.VideoCapture("MOV_0006.mp4")
print cap.get(cv2.cv.CV_CAP_PROP_FOURCC)
I tested this in two environment. In the first environment the opencv works, and in the other the opencv fails to play a video. But both printed out same codec 828601953.0.
I tried to change their codec by cap.set(cv2.cv.CV_CAP_PROP_FOURCC, cv2.cv.CV_FOURCC(*'H264')) but didn't work at all.
Try changing the libraries under opencv-2.4.8/3rdparty/lib/ into libraries in my workable environment. But couldn't even successfully build.
I grep AVC: nal size and find the libraries contain this error message are opencv-2.4.8/3rdparty/lib/libavcodec.a etc. That's why I tried to replace them. But it turns out that this is a bad idea.
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff4-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
Try to install some that thing and some this thing. But it was totally useless.
Problems Related
I've searched the web and there are many similar problems, but NONE of them had a solution!
Below are problems I think the same as mine.
OpenCV/ffmpeg does not play my mp4 video. —
from opencv-users.nabble.com
VideoCapture is not working in OpenCV 2.4.2 —
from answers.opencv.org
This one mentions rebuilding ffmpeg! But the arguments weren't enough for me.
Mp4 reading problem - I installed OpenCV 2.4.1 and python 2.7 and made a short program that reads the avi file successfully. However it fails to read mp4 file. —
from answers.opencv.org
Cannot open “.mp4” video files using OpenCV 2.4.3, Python 2.7 in _Windows 7 machine —
from Stack Overflow
OpenCV 2.4 VideoCapture not working on Windows —
from Stack Overflow
for ubuntu 14.04, this is how i fixed it.
install the dependencies required for OpenCV"
sudo apt-get remove ffmpeg x264 libx264-dev
sudo apt-get update
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff4-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
sudo add-apt-repository ppa:mc3man/gstffmpeg-keep
sudo apt-get update
sudo apt-get install gstreamer0.10-ffmpeg
sudo apt-get install gstreamer0.10-plugins-bad
sudo apt-get update
Install ffmpeg inside anaconda3"
conda install -c menpo ffmpeg=2.7.0
Dowload Opencv 3.1.0"
wget https://github.com/Itseez/opencv/archive/3.1.0.zip
unzip 3.1.0.zip
mkdir build
cd build
cmake -DBUILD_TIFF=ON -DBUILD_opencv_java=OFF -DWITH_CUDA=OFF -DWITH_FFMPEG=OFF -DENABLE_AVX=ON -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_IPP=ON -DWITH_TBB=ON -DWITH_EIGEN=ON -DWITH_V4L=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") -DPYTHON3_EXECUTABLE=$(which python3.5) -DPYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ..
make
sudo make install