Problem importing pylab in Ubuntu 8.1 - python

I have installed numpy1.3,scipy 0.7.1,matplotlib 0.99.1.1 and python 2.5
when I import pylab I get the following error. Someone please help.
/var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.py:72: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:44: GtkWarning: gdk_cursor_new_for_display: assertion `GDK_IS_DISPLAY (display)' failed
cursors.MOVE : gdk.Cursor(gdk.FLEUR),
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/usr/lib/python2.5/site-packages/matplotlib/pylab.py", line 247, in <module>
from matplotlib.pyplot import *
File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 78, in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/usr/lib/python2.5/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py", line 44, in <module>
cursors.MOVE : gdk.Cursor(gdk.FLEUR),
RuntimeError: could not create GdkCursor object

try using a different backend for plotting than Gtk.
Open the python console and type:
>>> import matplotlib
>>> matplotlib.matplotlib_fname()
This will print a file name. Edit this file and modify the section 'Backend' and change Gtk or GtkAgg with any other (see the documentation in the same file), until you get it working.
You can find more information about backends here.
As for why you get an error when you try to use that backend, it depends on how you have installed the libraries and what you have installed on your computer. I would recommend to install matplotlib with synaptic/yum and selecting all optional dependencies.

Related

Failed to import any qt binding - Spyder on Windows 10

I'm trying to animate a trajectory of an object in 2D using python.
The problem is, when i try to do so I get this famous error
Traceback (most recent call last):
File "C:\Users\Pierre\OneDrive\Documents\Etudes\Master\M2\Stage\tests\sympy and gekko.py", line 13, in <module>
import matplotlib.pyplot as plt
File "C:\Python39\lib\site-packages\matplotlib\pyplot.py", line 2336, in <module>
switch_backend(rcParams["backend"])
File "C:\Python39\lib\site-packages\matplotlib\pyplot.py", line 276, in switch_backend
class backend_mod(matplotlib.backend_bases._Backend):
File "C:\Python39\lib\site-packages\matplotlib\pyplot.py", line 277, in backend_mod
locals().update(vars(importlib.import_module(backend_name)))
File "C:\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Python39\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 11, in <module>
from .backend_qt5 import (
File "C:\Python39\lib\site-packages\matplotlib\backends\backend_qt5.py", line 16, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "C:\Python39\lib\site-packages\matplotlib\backends\qt_editor\figureoptions.py", line 11, in <module>
from matplotlib.backends.qt_compat import QtGui
File "C:\Python39\lib\site-packages\matplotlib\backends\qt_compat.py", line 177, in <module>
raise ImportError("Failed to import any qt binding")
ImportError: Failed to import any qt binding
I tried every solution I found (installing PyQt5 and importing it, reinstalling matplotlib, updating pip) and nothing works. I still get the same error every time.
I'm on windows 10 and I installed python (3.9.2) using chocolatey. I'm coding with spyder 4.2.2
I've seen someone speaking about how updating his GPU driver helped but mine is up to date and still nothing (Radeon RX580).
Does anybody have a clue on what could be the issue ?
Installing Pyside2 did the trick. No need to for the import PyQt5 if you have the option picked in the preferences of Spyder

when I “import nltk” show selectSelector error

>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hexialong/anaconda3/lib/python3.6/site-packages/nltk/__init__.py", line 89, in <module>
from nltk.internals import config_java
File "/Users/hexialong/anaconda3/lib/python3.6/site-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/Users/hexialong/anaconda3/lib/python3.6/subprocess.py", line 138, in <module>
import selectors
File "/Users/hexialong/anaconda3/lib/python3.6/selectors.py", line 290, in <module>
class SelectSelector(_BaseSelectorImpl):
File "/Users/hexialong/anaconda3/lib/python3.6/selectors.py", line 317, in SelectSelector
_select = select.select
AttributeError: module 'select' has no attribute 'select'
My environment is MacOS and python version is 3.6
select is a Python standard module. Maybe you should check that your python binaries are unbroken or just reinstall it.
Check that:
import select and select.select in Python Interactive Environment. If some errors generated, you'd better reinstall the python binaries.

Importing matplotlib in Spyder (OSX 10.6)

When importing matplotlib in Spyder I get the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/textpath.py", line 19, in <module>
import matplotlib.font_manager as font_manager
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/font_manager.py", line 57, in <module>
from matplotlib import ft2font
ImportError: dlopen(/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/ft2font.so, 2): Symbol not found: _inflateReset2
Referenced from: /Applications/Spyder-Py2.app/Contents/MacOS/../Frameworks/libpng16.16.dylib
Expected in: /usr/lib/libz.1.dylib
in /Applications/Spyder-Py2.app/Contents/MacOS/../Frameworks/libpng16.16.dylib
What can I do? I really don't get it. I run under mac OSX 10.6
(Spyder dev here) The problem lies in some changes done by the Matplotlib team some time ago that made for us harder to support Mac OSX 10.6.
To do it, we would need to include our own version of zlib in our Mac app, and compile every package against it, something I considered too much work and a potential cause of bugs.
That's why I changed the minimal required version of our app to be 10.7, as can be seen in our documentation site.

PyOpenGL-accelerate + numpy

I'm installing MakeHuman on Debian, so all dependencies was set up, but when launching it's an error:
SYS.PLATFORM: linux2
PLATFORM.MACHINE: x86_64
PLATFORM.PROCESSOR:
PLATFORM.UNAME.RELEASE: 2.6.32.26
PLATFORM.LINUX_DISTRIBUTION: debian 6.0.6
NUMPY.VERSION: 1.6.2
OpenGL_accelerate module loaded
Using accelerated ArrayDatatype
Unable to load numpy_formathandler accelerator from OpenGL_accelerate
Unable to load registered array format handler numeric
Traceback (most recent call last):
File "makehuman.py", line 310, in <module>
main()
File "makehuman.py", line 300, in main
from mhmain import MHApplication
File "./core/mhmain.py", line 32, in <module>
import mh
File "./lib/mh.py", line 29, in <module>
from glmodule import updatePickingBuffer, grabScreen, hasRenderSkin, renderSkin
File "./lib/glmodule.py", line 33, in <module>
from OpenGL.GL import *
File "/usr/lib/python2.7/dist-packages/OpenGL/GL/__init__.py", line 3, in <module>
from OpenGL.raw.GL.annotations import *
File "/usr/lib/python2.7/dist-packages/OpenGL/raw/GL/annotations.py", line 40, in <module>
'v',
File "/usr/lib/python2.7/dist-packages/OpenGL/arrays/arrayhelpers.py", line 197, in setInputArraySizeType
function.setPyConverter( argName, asArrayTypeSize(type, size) )
File "arraydatatype.pyx", line 393, in OpenGL_accelerate.arraydatatype.AsArrayTypedSizeChecked.__init__ (src/arraydatatype.c:7688)
AttributeError: 'module' object has no attribute 'sizeof'
Does anyone solve problems with link PyOpenGL+ numpy?
fixed that on my system by issuing:
sudo easy_install -U PyOpenGL
Noting:
using Ubuntu 12.04 LTS, with python2.7
did get a Permission denied error without that leading 'sudo'
via: http://matthew-4gl.wikispaces.com/python_modules ( in turn from https://bitbucket.org/ompl/ompl/issue/59/problem-with-ompl_apppy )
good luck

Trouble importing numba

Ok, I'm using python 3.3. I have numpy, llvm, llvmpy, llpyhton, llvm_array, llvm_cbuilder and llvmath installed. I have also installed numba.
However, when trying to import via import numba, the following error appears. I have no idea of what could be missing:
Traceback (most recent call last):
File "/home/pablo/workspace/Pruebas/src/Prueba2/__init__.py", line 1, in <module>
import numba
File "/usr/local/lib/python3.3/dist-packages/numba/__init__.py", line 18, in <module>
from numba import utils, typesystem
File "/usr/local/lib/python3.3/dist-packages/numba/utils.py", line 102, in <module>
context = get_minivect_context()
File "/usr/local/lib/python3.3/dist-packages/numba/utils.py", line 100, in get_minivect_context
return NumbaContext()
File "/usr/local/lib/python3.3/dist-packages/numba/minivect/miniast.py", line 138, in __init__
import llvm.core as llvm_py_not_available # llvm-py not available
File "/usr/local/lib/python3.3/dist-packages/llvm/__init__.py", line 6, in <module>
from llvmpy import extra
File "/usr/local/lib/python3.3/dist-packages/llvmpy/extra.py", line 6, in <module>
from llvmpy import _api
ImportError: libLLVM-3.2.so: cannot open shared object file: No such file or directory
Any ideas?
Ok, I found out what was wrong.
I added the anaconda folders to the deafault python3 interpreter, instead of installing numba directly in the packages folder.

Categories

Resources