I'm trying to use the EasyDialogs python module to produce some simple dialog boxes for my python script on OSX. Whenever I try and import the EasyDialogs module I get the following error:
>>> import EasyDialogs
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/EPD64.framework/Versions/6.2/lib/python2.6/plat-mac/EasyDialogs.py", line 24, in <module>
from Carbon.Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog
File "/Library/Frameworks/EPD64.framework/Versions/6.2/lib/python2.6/plat-mac/Carbon/Dlg.py", line 1, in <module>
from _Dlg import *
ImportError: No module named _Dlg
I've tried doing easy_install Carbon, as I thought it may be due to some issue with the Carbon package for python, but that hasn't helped. Any ideas?
From the paths in your traceback, you appear to be using a 64-bit Enthought Python Distribution. The EasyDialogs module uses various OS X Carbon interfaces, many of which OS X only provides 32-bit versions and have been deprecated by Apple. For this reason, the Python Carbon wrapper and EasyDialogs modules are deprecated in Python 2 and have been removed in Python 3. While they may work in 32-bit mode, you should avoid using them in new code. There are other alternatives available: Tkinter in the standard library, various cross platform GUI frameworks (see here). For more simple dialogs, you could also use the osax package in appscript to use the User Interaction suite of AppleScript's Standard Additions.
Related
Good day,
I recently tried to upgrade to Python 3.6.1 by building from source, and I've had a few issues.The first of which had to do with the $PYTHONHOME environment variable, which I have now (seemingly) solved, whereas the second - and most persistent - has to do with me not being able to access many modules.
For instance, when I launch the python3 interpreter, I immediately encounter an error that states:
Traceback (most recent call last): File "/etc/pythonstart", line 7,
in
import readline ModuleNotFoundError: No module named 'readline'
Similar errors occur with other modules that are imported by other scripts, such as 'encodings'
ImportError: No module named 'encodings'
and '_socket'
ModuleNotFoundError: No module named '_socket'
I'm not used to building from source, so I just used the instructions in the readme file that comes with the Python 3.6.1 tar ball, without much understanding of what's going on. I performed this procedure over and over again, (hopefully that didn't add to the problems), and here's the latest error output from the make test command:
Traceback (most recent call last): File
"./Tools/scripts/run_tests.py", line 12, in
import test.support
File "/usr/local/lib/python3.6/test/support/init.py", line 15, in
import logging.handlers
File "/usr/local/lib/python3.6/logging/handlers.py", line 26, in
import logging, socket, os, pickle, struct, time, re
File "/usr/local/lib/python3.6/socket.py", line 49, in
import _socket ModuleNotFoundError: No module named '_socket'
Makefile:1018: recipe for target 'test' failed make: *** [test] Error 1
I've searched all over the web frantically and I can't seem to find anything that really captures my problem, as the many other problems I've seen often involve people not being able to access only one module, or the solutions provided are extremely specific and seem difficult to generalise from (such as solutions that make use of lengthy Debian-based commands). I sincerely apologise if there are general solutions to this problem that I just haven't found.
Additionally, when I try to launch the Python 2 interpreter, I just get this error (and it fails completely):
ImportError: No module named site
My system information:
OS: Opensuse Leap 42.2
Previous Python3 version: 3.4.5 Current
Python3 version: 3.6.1
Your help with this matter would be greatly, greatly appreciated!
I have Linux Ubuntu x64 14.04 with Python 3.4 installed (default installation by Ubuntu).
If I open CudaText text editor, it cannot import ctypes in console:
>>>> import ctypes
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.4/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: /usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so: undefined symbol: PyFloat_Type
Seems like Py3.4 installation is not full? Why it cannot load ctypes?
In Debian Linux distros such as Ubuntu, Python extension modules are built assuming Python's symbols are loaded globally, so they don't explicitly list the Python lib as a requirement in the ELF header. An embedding application that links dynamically needs to load the Python shared library to the global symbol table, e.g. dlopen("libpython3.4m.so", RTLD_GLOBAL | RTLD_NOW).
The author of the CudaText editor is using Python for Lazarus. I presume this uses dynlibs. As you can see in the source, it does not call dlopen with RTLD_GLOBAL. The default is RTLD_LOCAL (0).
I can import gtk without any problem previously. I made a GUI in glade for GTK+ 3. Then I thought that I would like to try GTK+ 3. So I installed PyGObject. I later found out that PyGObject has little documentation and I'm using Windows (makes things worse I know).
The problem is here, I can't use import gtk anymore. Neither can I use from gi.repository import Gtk. I've tried installing PyGTK bundle again but it doesn't help.
>>> import gtk
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import gtk
File "C:\Python27\lib\site-packages\gtk-2.0\gtk\__init__.py", line 30, in <module>
import gobject as _gobject
File "C:\Python27\lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in <module>
from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
File "C:\Python27\lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <module>
from glib._glib import *
ImportError: DLL load failed: The specified procedure could not be found.`
This looks like C-level library is missing, or at least in a place where the Python wrappers can't find it. Try re-installing whichever version of the C library corresponds to which Python library you would like to use (GTK2 and GTK3 should, theoretically, be parallel installable, but that installing the newer PyGobject broke import gtk suggests that at least these particular bindings aren't for some reason).
I am trying to use ryp with my arcpy scripts but I have the following error:
import rpy2.robjects as robjects Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module> import rpy2.robjects as robjects
File "C:\Python26\ArcGIS10.0\lib\site-packages\rpy2\robjects\__init__.py", line 12, in <module> import rpy2.rinterface as rinterface
File "C:\Python26\ArcGIS10.0\lib\site-packages\rpy2\rinterface\__init__.py", line 39, in <module> import win32api
ImportError: No module named win32api
This error comes even after the installation of the pywin32 for my version of python.
I've noticed that this seems to be a common error that is usually solved with the installation of pywin32.
I also have a problem with the matplotlib installation, every time i try to use it (import matplotlib.pyplot as plt), python crashes...
Versions:
Python 2.6.6
matplotlib installation: matplotlib-1.1.0.win32-py2.6.exe
You will need to run these scripts with PROPER Python. It seems to me that the ArcPy distribution does not include the win32api module (It also does not exist from example in Python on Mac or Linux).
I would install PythonXY which includes R bindings, and see if your scripts run there. If they run there, then I (guess) I am correct, and ArcPy does not include these modules.
A nice BONUS of PythonXY is it's an excellent Python IDE (Spyder), but the real bonus is what the commenter above me said:
different compiler versions can cause hell of a lot of Problems.
So, in PythonXY you get a whole bundle compiled with the same compiler.
Let us know if these made your RPy script run.
I am trying to run my GTK app on Windows XP and I am having troubles with an import. I have installed the following as needed and recommended:
python-2.6.msi
gtk2-runtime.2-16.6.exe
pycairo-1.8.6.exe
pygobject-2.20.0
pygtk-2.16.0.exe
pyserial-2.5.exe
However, I am getting the following error when running my script:
Traceback (most recent call last):
File "C:\python26\app\src\start.py", line 22, in <module>
import gtk
File "C:\Python26\Lib\site-packages\gtk-2.0\gtk\__init__.py", line 30, in <mod
ule>
import gobject as _gobject
File "C:\Python26\Lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in
<module>
from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
File "C:\Python26\Lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <mo
dule>
from glib._glib import *
ImportError: DLL load failed: The specified module could not be found.
GTK is installed into C:\gtk\bin and is setup in my System PATH.
Am I missing something obvious here?
Any help would be appreciated.
Thank-you kindly.
Andy
I was getting the same issue - I'm not sure why, but I suspect it has something to do with some of the install/lookup paths. I tried adding all sorts of stuff to my path, but nothing seemed to work.
What I did to fix it was to uninstall python et. al. and reinstall using the Python (x,y) package. It's a fairly large download, but it has tons of tools, including several (matplotlib, numpy, scipy, IPython, etc) that I needed/wanted.
You could install pygtk bundle found in this page:
http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/
where you should find the "all in one" installer suited to your version.
It solved the problem to me without having to install Py(x,y), which seems to be a very usefull scientific environment for windows (I use linux and install all these packages from script).