Importing wxPython fails in Maya - python

When I try to import wxPython from Maya (or mayapy), I get an import error:
[/c] ==> mayapy
Python 2.6.4 (r264:75706, May 19 2011, 13:53:43) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\wx-3.0-msw\wx\__init__.py", line 45, in <module>
from wx._core import *
File "c:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\wx-3.0-msw\wx\_core.py", line 4, in <module>
import _core_
ImportError: DLL load failed: The specified module could not be found.
Question:
How do I make wxPython work with Maya's Python installation?
Context:
I use PyQt, PySide and Tkinter for my UI development with Maya Python. I want to use wxPython just to try it out. I installed the version of wxPython that was meant for Python 2.6/Win64. It is installed in Maya's Python folder: C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\
I tried installing wx for a standard installation of Python 2.6 and it works fine. That is the reason I am posting this question; I am looking for a solution for why this is happening only for the Maya Python installation and not the other standard Python installation that I have.
I am using:
Maya version: 2013
Maya Python version: 2.6.4
OS: Windows 7, 64-bit.
Thank you for any help or suggestions you can give.

There are a couple of reasons you could be getting that message. Some have reported that this happens if you install a 64-bit wxPython to a 32-bit Python (or vice-versa), although I personally don't know how you could do that. That is something to check though as if you have a 64-bit vs 32-bit mismatch, you will definitely have issues.
The other more likely issue is that you need to install a Microsoft redistributable so that you have the correct DLL that wxPython needs.
"import wx" fails after installation of wxPython on Windows XP
wxPython Import Error: DLL load failed

Related

ImportError with PySide6/shiboken6

I'm trying to get PySide6 to run in Python 3.8.0. Installation went fine:
C:\>pip install pyside6
Collecting pyside6
Using cached PySide6-6.0.0-6.0.0-cp36.cp37.cp38.cp39-none-win_amd64.whl (62.4 MB)
Collecting shiboken6==6.0.0
Using cached shiboken6-6.0.0-6.0.0-cp36.cp37.cp38.cp39-none-win_amd64.whl (2.3 MB)
Installing collected packages: shiboken6, pyside6
Successfully installed pyside6-6.0.0 shiboken6-6.0.0
but i'm hit with an import error:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySide6
PySide6/__init__.py: Unable to import shiboken6 from , C:\Python38\python38.zip, C:\Python38\DLLs, C:\Python38\lib, C:\Python38, C:\Python38\lib\site-packages
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python38\lib\site-packages\PySide6\__init__.py", line 107, in <module>
_setupQtDirectories()
File "C:\Python38\lib\site-packages\PySide6\__init__.py", line 57, in _setupQtDirectories
import shiboken6
File "C:\Python38\lib\site-packages\shiboken6\__init__.py", line 25, in <module>
from .shiboken6 import *
ImportError: DLL load failed while importing shiboken6: The specified procedure could not be found.
What did i do wrong?
What did i do wrong?
I don't believe you did anything wrong.
I think this was a known bug in shiboken6 versions <=6.0.0. It was reported partly in the PySide bug tracker: PYSIDE-932.
The issue appeared to be that they were attempting to import from a zip file. From the comments in version 6.3.0 of shiboken6.__init__:
# PYSIDE-932: Python 2 cannot import 'zipfile' for embedding while being imported, itself.
# We simply pre-load all imports for the signature extension.
# Also, PyInstaller seems not always to be reliable in finding modules.
# We explicitly import everything that is needed:
The comment says Python 2 cannot import, but it should read PySide2 cannot import because the issue came from Python 3.6 using PySide 2.
The Qt Docs mention using a newer version of virtualenv to fix this problem, but I do not believe virtualenv is the culprit. Moreover, the latest Python 3 versions ship with and use venv. Instead, I believe this was an issue with importing zip files. It may have been resolved when Barry Warsaw/Brett Cannon and their team introduced importlib.resources in newer versions of Python 3, which can particularly help with zip files.
See their talk here:
Barry Warsaw - Get your resources faster, with importlib.resources - PyCon 2018
Ultimately, I believe this was resolved in the latest version of shiboken6 (i.e. 6.3.0).
Give that a try and see if that works.

ImportError importing ssl in MinGW-W64 Python 3.6

I've used MSYS2 to install the MinGW-W64 version of Python 3.6 (mingw-w64-x86_64-python3). Upon importing ssl, an ImportError is raised:
$ python3
Python 3.6.2 (default, Aug 15 2017, 10:59:43) [GCC 7.1.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "G:/msys64/mingw64/lib/python3.6\ssl.py", line 101, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.
>>>
I'm not sure why this. pacman shows both mingw-w64-x86_64-openssl and openssl as installed. /mingw64/lib/python3.6/lib-dynload/_ssl-cpython-36m.dll exists. Other .dll files from the same directory (like those used for the json and sqlite3 modules) import fine.
To make matters weirder, the Python 2 version (mingw-w64-x86_64-python2) doesn't have this problem.
This is not a correct solution (the MSYS2 folks are working on the real solution), but as a temporary workaround for anyone else who gets stuck on this:
After installing mingw-w64-x86_64-python3 copy
C:\msys64\mingw64\bin\LIBEAY32.dll and
C:\msys64\mingw64\bin\SSLEAY32.dll
to
C:\msys64\mingw64\lib\python3.6\lib-dynload\LIBEAY32.dll and
C:\msys64\mingw64\lib\python3.6\lib-dynload\SSLEAY32.dll respectively.
Afterwards import ssl (and tools that rely on it, like pip3) should work correctly.

Error importing gi

This is the command I am trying to run and its output:
$ python2
Python 2.7.8 (default, Sep 24 2014, 18:26:21)
[GCC 4.9.1 20140903 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: /usr/lib/python2.7/site-packages/gi/_gi.so: undefined symbol: g_type_check_instance_is_fundamentally_a
I have searched for this error, but could not find anything that helped.
These are the packages that I have installed:
$ pacman -Qs python
local/pygtk 2.24.0-3
Python bindings for the GTK widget set
local/python 3.3.4-1
Next generation of the python high-level scripting language
local/python-dbus-common 1.2.0-2
Common dbus-python files shared between python-dbus and python2-dbus
local/python-gobject 3.14.0-2
Python 3 bindings for GObject
local/python-gobject2 2.28.6-11
Python 3 bindings for GObject2
local/python2 2.7.8-2
A high-level scripting language
local/python2-cairo 1.10.0-1
Python2 bindings for the cairo graphics library
local/python2-dbus 1.2.0-2
Python 2.7 bindings for DBUS
local/python2-distutils-extra 2.38-1
Enhancements to the Python build system
local/python2-gobject 3.14.0-2
Python 2 bindings for GObject
local/python2-gobject2 2.28.6-11
Python 2 bindings for GObject2
local/python2-pillow 2.3.0-3
Python Imaging Library (PIL) fork. Python2 version.
local/python2-xdg 0.25-1
Python library to access freedesktop.org standards
Dont know what I am missing here..
Solved:
Error was due to older version of glib2 package.
This might be not a Python problem nor your code problem. /usr/lib/python2.7/site-packages/gi/_gi.so might be corrupted or compiled badly. Maybe you've put it in the wrong path.
How to solve: upgrade glib2

How do I install Pygame on Windows8 to work with Python 3.3.3?

Speaking as someone who is new to stackoverflow and not that computer literate...
How do I get Pygame to work? I have been using IDLE (python GUI), Python version 3.3.3, and I want to add on Pygame. I downloaded and installed "pygame-1.9.2a0-hg_56e0eadfc267.win32-py3.3.msi" from Bitbucket and then tried to "import pygame" but got the following output in my window:
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600
64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
import pygame Traceback (most recent call last):
File "", line 1, in
import pygame
File "C:\Program Files
(x86)\Python333\lib\site-packages\pygame__init__.py", line 127, in
from pygame.base import *
ImportError: DLL load failed: %1 is not a valid Win32 application.
Does anyone know what is wrong, and how I can fix it?
Many thanks
L.
Direct quote from the site
windows 64bit users note: use the 32bit python with this 32bit pygame.
Also an extension to #Marius 's comment, you can get a pre-release 64 bit version of pygame here http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

Pycuda installation on Ubuntu

I'm having a difficult time installing pycuda. I am running on Ubuntu 12.04. I first installed the Enthought python distribution (even though I already had python on the computer). I added the enthought python location to the path in my .profile (and this works without issue, typing python or ipython from the command line correctly uses the enthought version). I then followed the instructions from http://wiki.tiker.net/PyCuda/Installation/Linux/Ubuntu (skipping steps 0-1 as I already had numpy and cuda installed).
Everything seems to run and install fine. But when I try to actually use pycuda, it fails. For example, here's what happens when I try to run the hello_gpu.py example:
:~/Downloads/pycuda-2012.1$ python examples/hello_gpu.py
Traceback (most recent call last):
File "examples/hello_gpu.py", line 1, in <module>
import pycuda.driver as drv
File "/usr/lib/python_enthought/lib/python2.7/site-packages/pycuda-2012.1-py2.7-linux- x86_64.egg/pycuda/driver.py", line 2, in <module>
from pycuda._driver import *
ImportError: /usr/lib/libboost_python-py27.so.1.46.1: undefined symbol:
PyUnicodeUCS4_FromEncodedObject
Alternatively, when I try to import the pycuda package from idle, I get a different error:
Python 2.7.3 |EPD 7.3-1 (64-bit)| (default, Apr 11 2012, 17:52:16)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "credits", "demo" or "enthought" for more information.
>>> import pycuda
>>> pycuda
<module 'pycuda' from 'pycuda/__init__.pyc'>
>>> import pycuda.driver as drv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pycuda/driver.py", line 2, in <module>
from pycuda._driver import *
ImportError: No module named _driver
I suspect part of the issue is me somewhere not specifying the correct path to the python interpreter, but I cannot figure out where this error occurs. Any suggestions would be most welcome, I am out of ideas.
This problem would appear to have been caused by conflicts between two different Python installations on the same system. The OP apparently solved this by uninstalling an Enthough Python installation and using only the system Python installation. There might well be other ways to solve this using a non-system Python installation, as suggested here
[This answer was assembled from comments and added as a community wiki entry in the hope it will receive a vote and be removed from the unanswered list for the PyCUDA tag]

Categories