I am using anaconda [python 2.7] on ubuntu machine [15.04].
I need opencv, pygame, python 2.7 for my code to run.
I get the error on running my code:
Traceback (most recent call last):
File "deep_q_network.py", line 8, in <module>
import wrapped_flappy_bird as game
File "game/wrapped_flappy_bird.py", line 19, in <module>
IMAGES, SOUNDS, HITMASKS = flappy_bird_utils.load()
File "game/flappy_bird_utils.py", line 21, in load
pygame.image.load('assets/sprites/0.png').convert_alpha(),
pygame.error: File is not a Windows BMP file
Hours spent on this making the fix. TRied SO solutions. PLease help. Thanks.
Read the error: File is not a Windows BMP file. The image you're trying to load seems to be a .png: assets/sprites/0.png. To fix, save the image as a .bmp. Your pygame is missing support for other formats. Documentation quote:
The image module is a required dependency of Pygame, but it only
optionally supports any extended file formats. By default it can only
load uncompressed BMP images. When built with full image support, the
pygame.image.load() function can support the following formats.
To fix it, you need to install python imaging libraries.
Related
I need an automatic speech transcription tool for my video editing project. I am using python speech recognition library. To split big audio file into small fractions I installed pydub and added its functionality in my script. Although I checked and solved the env-path issues of ffmpeg it still giving the following error:
Traceback (most recent call last):
File "..\VideoEditing\speech_transcript.py", line 4, in <module>
from pydub import AudioSegment
ModuleNotFoundError: No module named 'pydub'
What could be done to solve this issue, any ideas?
Many thanks..
Finally I found the solution. Just changed the directory of the downloaded package of pydub to:
"C:\Users\Username\AppData\Local\Programs\Python\Python36\Lib\site-packages".
Many thanks.
I'm pretty frustrated and I'm not even sure where to start. I'm trying to install python arcade and it's going poorly. I'm trying to run one of the tutorial scripts and I get back the following error.
Traceback (most recent call last):
File "", line 4, in
import arcade
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/arcade/init.py", line 103, in
from .drawing_support import calculate_hit_box_points_detailed
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/arcade/drawing_support.py", line 7, in
import pymunkoptions
ModuleNotFoundError: No module named 'pymunkoptions'
pymunk is saying it's installed. Does arcade not work on python 3.9?
I had the same problem.
I got round it by specifying that the version of pymunk needs to be 5.7.0 (apparently it's been updated since 5.7.0 and Arcade still needs to tweak some things to work properly).
In the requirements.txt in Pycharm (if you're following the instructions here: https://arcade.academy/venv_install/index.html), I put both:
arcade
pymunk==5.7.0
Did the trick for me.
File paths were setup incorrectly.
I have a problem loading PNG images in Gtk3.
I have broken image symbols in my ToolButtons and after some investigation it appears that it comes from GdkPixbuf not being able to read the PNG files.
I have reproduced the problem with the python console
>>> from gi.repository import GdkPixbuf
>>> print(GdkPixbuf)
<gi.module.DynamicModule 'GdkPixbuf' from '/home/user1/ctcils/dusserm/applications/gobject-introspection/1.40.0/lib/girepository-1.0/GdkPixbuf-2.0.typelib'>
>>> GdkPixbuf.Pixbuf.new_from_file("/home/user1/ctcils/dusserm/applications/pycharm-community-3.4.1/bin/pycharm.png")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
gi._glib.GError: Couldn't recognize the image file format for file '/home/user1/ctcils/dusserm/applications/pycharm-community-3.4.1/bin/pycharm.png'
Many of the problems I faced in the last days were due to the fact we had to compile Gtk3, pygobject and all their dependencies and to install them in non-standard directories.
I suspect a problem with the gobject introspection (the last from a long list).
Not a full answer but some debugging tips: Check what image loaders gdk-pixbuf is providing (see also What image formats are supported by Gdk-Pixbuf (Gtk-Image?) by Default?). A Python snippet to check this:
from gi.repository import GdkPixbuf
for fmt in GdkPixbuf.Pixbuf.get_formats():
print(fmt.get_extensions())
If nothing shows up, gdk-pixbuf is not finding any loaders which probably has something to do with the install location (--prefix and/or --libdir configure options). Verify you have loaders installed into the location gdk-pixbuf expects to find them (especially the png loader). This should be something like: <prefix>/lib[64]/gdk-pixbuf-2.0/<version>/loaders
See also: https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-query-loaders.html
I got a similar error with unusual prefix, and solved it by setting XDG_DATA_DIRS, which I didn't have set.
export XDG_DATA_DIRS=.../usr/share
Source: https://bugs.gentoo.org/644136
It seems that the problem was due to the PNG library itself.
I am quite surprised considering that it comes from a regular CentOS rpm libpng-1.2.49-1.el6_2.x86_64 and that PNG is a stable standard for ages. In addition we did not have the problem with GTK2 that was using the same lib I suppose...
Anyway, I compiled a bright new libpng 1.6.2 from the sources, I re-configured and re-installed gdk-pixbuf and now it works.
I am trying to work with OpenCV in Python 2.7, however when I simply import cv2, I am getting this error:
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cv2.py", line 9, in <module>
from VideoCapturePlayer import *
ImportError: No module named VideoCapturePlayer
I figured that VideoCapturePlayer may be in pygame or pycam, but when I import both, no problems arise.
I have searched my folders and the web for VideoCapturePlayer. My folders do not contain it, and the internet provided a .py file, but I do not know where I should put it. Any help is greatly appreciated, thank you.
Edit: I guess I should include that I am on Windows 7 64-bit
The link you provided is for downloading the entire OpenCV project, including all the libraries and bindings for C++, Java, etc. etc. For the Python bindings, it's much easier to visit my favorite module site on the Internet, Christoph Gohlke's Python Extension Packages for Windows repository. Find the OpenCV section, pick AMD64 or Win32, pick py2.7 or py2.6, and wait a bit for the self-extracting archive to download. Run it, hit OK for all the prompts, and you should be all set. Fire up IDLE or run python from the command line, and running import cv2 should give you no response at all - indicating that everything got set up just fine.
Good luck!
I'm doing some image analysis for my research, and it involves using CellTool (http://pantheon.yale.edu/~zp2/Celltool/), Python, and numpy. I'm on a OS X 10.8.3. On my old laptop that crashed, I was able to run my commands fine, but I got a new one and things are not going as smoothly!
I believe I have CellTool and numpy installed correctly, and I'm just using Python 2.7.2 that's standard on Mac. But when I try to run this python script "calculate_distances.py" command, I get this error:
Yuxins-MacBook-Pro:Modified_Contours yuxinsun$ python calculate_distances.py
Traceback (most recent call last):
File "calculate_distances.py", line 24, in <module>
normals = contours[n-1].inward_normals()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/contour/contour_class.py", line 384, in inward_normals
import celltool.numerics.fitpack as fitpack
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/numerics/fitpack/__init__.py", line 1, in <module>
from fitpack import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/numerics/fitpack/fitpack.py", line 34, in <module>
import _fitpack
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/numerics/fitpack/_fitpack.so, 2): Library not loaded: /usr/local/lib/libgfortran.2.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/celltool/numerics/fitpack/_fitpack.so
Reason: image not found
And I have no idea what any of it means...I only need to run this python script and get the file that it spits out.
Am I just missing the "fitpack" whatever that is? If so, how do I install it? Or what can I do to fix this problem.
You need to make sure you have those installed per installation requirements:
If one of the above binary installers did not suit your needs,
please install Celltool from the source code.
This depends on only three things:
1.Python (version 2.3 or later).
2. NumPy 1.0.4 or later.
3. Working C/C++ and Fortran compilers.
and it looks like your Fortran compiler libs are not installed.
This might be helpful: https://scicomp.stackexchange.com/questions/2469/how-should-i-install-a-fortran-compiler-on-a-mac-os-x-10-x-x-4