wxPython version issue - python

Running Ubuntu 14.04 with Eclipse Kepler Service Release 2 which has Pydev 4.4.0.2... and Pydev Mylyn Integration 0.6.0. My program runs with no issues. Porting it over to my new platform running Ubuntu 16.04 with Eclipse Oxygen 1A release 4.7.1A and Pydev 6.0.0... with Pydev Integration at 0.6.0 and get the following error:
from wxPython._gdi import wxBitmapFromImage
ImportError: No module named wxPython._gdi
I can import wx either in Eclipse (Console) or on a terminal shell in the new ubuntu version but get the 2nd line error when I type the 1st line. My 14.04 is running wxpython 2.8 while my new 16.04 is running 3.0 not sure if this is it however.

I had the same issue except I got it on unpiclikg an instane of _gdi.Colour class. Following advice from Unpickling python objects with a changed module path I was saved with:
import wx as _wx
from wx import _core
sys.modules['wx._gdi'] = _core
This is a hack of course and you should be better off with a try-except as in (untested)
try:
from wxPython._gdi import wxBitmapFromImage
except ImportError:
from wx import BitmapFromImage as wxBitmapFromImage

The wxPython namespace is very, very old. As in more than a decade. If I remember correctly it was deprecated in 2.7 and provided only as a thin compatibility shim in 2.8, with the intent that all should have migrated to the new wx namespace by then. The compatibility shim was removed in 2.9.
The gist of the changes is that names like wxFrame located in the wxPython namespace or one of its submodules have been changed to names like Frame in the wx namespace. In other words, it should be used like this: wx.Frame.

Related

Change title of tkinter app in Mac OSX new versions

I have been using the answer provided here and that works just fine under Python 3.7 using pyobjc 6.1
Change title of Tkinter application in OS X Menu Bar
However I am starting a new project and am using Python 3.8 and the latest pyobjc 8.1 and even though pyobjc is installed and I can see it in the path I get the error
from Foundation import NSBundle
ModuleNotFoundError: No module named 'Foundation'
I'm at a loss now as to how to get it working again.

matplotlib does not import PyQt4, PyQt5 or PySide

I'm using Canopy 2.1.3 distribution (on Ubuntu 16.04) which as you may know contains the matplotlib package. Simply running in the Canopy's shell import matplotlib.pyplot as plt gives me
ImportError: Matplotlib qt-based backends require an external PyQt4, PyQt5,
or PySide package to be installed, but it was not found.
I have installed all of the three packages with Synaptic but the problem persists.
Could this be related to environment variables? Or, could it be because Canopy's Python 3.5 and Ubuntu's Python 2.7 are conflicting?
EDIT:
I have finally used the PyQt by installing it from the Canopy's package manager.
It is likely that the default backend for matplotlib.pyplot is set to qt.
I have very little experience with canopy, but it should be possible to change the default to another back end; maybe someone else will be able to tell you how, or you can find it by yourself.
In the meantime, you can try to add this above all other matplotlib imports:
import matplotlib
matplotlib.use('TkAgg')
From the user guide:
Known Issue: In Canopy running Python 3, GUI backend must be explicitly set
If you ask matplotlib to display a plot, or otherwise run Python code that creates a GUI window, by default you will get an error traceback ending with: ImportError: No module named 'PyQt4'
The solutions are to install PyQt (which is GPL-licensed) in the Canopy Package Manager, or to use the Canopy Preference menu’s Python tab to specify the TK PyLab backend for creating GUIs. For details, see “Python 3 in Canopy 2 - ‘No module named PyQt4’ error”

Import Error embedding IPython into PyQt application

I have a fully functioning PyQt4 based application that I am now trying to embed an IPython console into for use as a kind of scripting environment.
I've roughly adapted the example from IPython's Github page to fit into my application's module system. However, if any PyQt import happens before the IPython imports
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.qt.inprocess import QtInProcessKernelManager
I get the following error:
ImportError:
Could not load requested Qt binding. Please ensure that
PyQt4 >= 4.7 or PySide >= 1.0.3 is available,
and only one is imported per session.
Currently-imported Qt library: 'pyqtv1'
PyQt4 installed: True
PySide >= 1.0.3 installed: False
Tried to load: ['pyside', 'pyqt']
I've traced this error to IPython's qt module, but essentially forcing 'pyqtv1' to be loaded (by replacing api_opts = [QT_API] with api_opts = ['pyqtv1'] breaks QString inside the IPython window.
However, if I make it so that those imports happen first (by importing the module this code is in before anything else), that error goes away and it basically breaks QString completely with an ImportError: cannot import name QString.
I've verified that if I make a self-contained QApplication in the module that contains the IPython instance, making sure to import PyQt.QtGui after doing the IPython imports, it works ask expected. It's only when I try and mix the IPython code with any other PyQt code that things break.
Any suggestions as to how to fix the error?
I'm on Ubuntu Linux 12.04, and IPython is version 2.0.0-dev pulled on March 10th.
PyQt offers two different APIs for strings: you can choose which one to use with code like this:
import sip
sip.setapi('QString', 2)
from PyQt4 import QtGui
Once you import PyQt4, that API is set and cannot be changed. On Python 2, it defaults to version 1 for backwards compatibility, but IPython requires API version 2. Version 2 is the default on Python 3, and PySide's API is equivalent to version 2.
If you've used the v1 API in your application, you cannot use the IPython Qt console embedded in that application, except by porting it to the v2 API. However, you can embed an IPython kernel in your application, and connect to it from a Qt console in a separate process.

How to get wxPython 2.9.4 running on Windows XP with Python 3.3.2?

Hmm, I'm missing something. I installed wxPython under Python33. When typing 'import wx', I am getting an error message:
ImportError: No module named 'wx'
Someone knows what this is about?
I looked at this Q&A on here: "“import wx fails after installation of wxPython on Windows XP" and "importing the wx module in python" but it's vaguely related to my issue. This one "Python ImportError: No module named wx" seems to have good answers, but I don't know how to add C:\Python33\site-package\wx-2.9.4-msw to my PYTHONPATH environment variable.
Obviously, I am too new for this and asking banal questions. However, I trust someone is willing to provide an answer.
Project Phoenix is in alpha, but IS available for Python 3 right now. You can get a snap shot build here: http://wxpython.org/Phoenix/snapshot-builds/ FYI: Project Phoenix only supports the standard widgets with very limited support for the custom modules at the time of this writing.
The standard "classic" build for wxPython 2.9 does NOT currently support Python 3.
For information about setting PYTHONPATH, see the following:
http://www.blog.pythonlibrary.org/2011/11/24/python-101-setting-up-python-on-windows/
http://docs.python.org/2/using/windows.html
How to add to the pythonpath in windows 7?
wxPython does not support Python 3. You will have to use Python 2.7.
Project Phoenix is aiming to support Python 3, but this is still in development.

Python _ctypes import error on OSX 10.6

I'm very new to Python development, and am having a problem with one of my apps in OSX.
Technologies being used in this project
python 2.6
django
google app engine
rpx (openid)
When loading up the site on my windows app, there are no issues, but when trying to same app on OSX 10.6, I get the following issue:
ImportError at /rpx/rpx/login/
No module named _ctypes
Here's where the error is happening:
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/init.py in
#
"""create and manipulate C data types in Python"""
import os as _os, sys as _sys
version = "1.1.0"
from _ctypes import Union, Structure, Array
Any ideas? Thanks!
OS X 10.6's Python 2.6 does include ctypes by default. You can even see part of it in the error report. So if there's a problem with the installation, it's only a problem with part of ctypes. That suggests that either it was damaged somehow or that something else is interfering with some part of the ctypes internals.
Google App Engine is a prime candidate for this interference. ctypes itself is not available on Google App Engine.
It looks like this might be a specific interaction between Python 2.6, OS X, and Google App Engine. Likely the same problem would not be encountered if you actually upload your application to GAE for real deployment.
This issue has been raised in the GAE issue tracker here: http://code.google.com/p/googleappengine/issues/detail?id=985
The last comment there suggests changing your GAE preferences to use Python 2.5 (/usr/bin/python2.5) as a possible resolution to the issue on your OS X development machine.
I don't have enough rep to comment so I will make this a post.
The accepted answer is correct in that all you need to do is set the Python Path in the GAE preferences to /usr/bin/python2.5.
There is no need to download python 2.5 via macports or from the official python website.
python 2.5 is still installed in OSX 10.6, it is just not the default python interpreter. For this reason you need to tell GAE explicitly to use version 2.5.
FWIW I'm using GAE Launcher 1.4.1
I was using python 2.6.1 on my Mac OS X Snow Leopard 10.6.3.
Follow the steps bellow to solve this problem:
1) Download and install python 2.5.2: http://www.python.org/download/releases/2.5.2/
2) Run GoogleAppEngineLauncher.app
3) Open Preferences --> and change "Python Path:" to "/usr/local/bin/python2.5"
There's no reason to use python 2.6.1 because GAE uses 2.5.
via vitor...#gmail.com
The only thing that I can think of is that maybe it's not on your path. Seems unlikely, but I would check that anyways.

Categories

Resources