Pycuda installation on Ubuntu - python

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]

Related

While importing pandas in python version 3.10, getting errors related to incompatible architecture

I have python 3.9 and 3.10 versions installed on my Mac.I am currently using only V3.10 for programming. In VSCode and Jupiter notebook, if I try importing pandas I am not getting any errors and import works fine. But when I try the importing the same in Atom, I get the below error:
python3.10
Python 3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.10 from "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10"
* The NumPy version is: "1.22.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_uma
th.cpython-310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core
/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib
/_multiarray_umath.cpython-310-darwin.so' (no such file)
The command file ${which python} yields the foll. output:
file $(which python)
/usr/bin/python: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executa
ble arm64e]
/usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture arm64e): Mach-O 64-bit executable arm64e
I have tried multiple ways of resolving it installing/uninstalling few times but the error keeps coming.

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.

Python3, can't import numpy

I am unable to import numpy.
Tried to uninstall and reinstall numpy by using pip and pip3.
Checked PATH.
I am using Python3 on Windows 10.
Below is the whole error:
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import numpy
Traceback (most recent call last):
File "C:\Python37\lib\site-packages\numpy\core__init__.py", line 40, in
from . import multiarray
File "C:\Python37\lib\site-packages\numpy\core\multiarray.py", line 13, in
from . import overrides
File "C:\Python37\lib\site-packages\numpy\core\overrides.py", line 6, in
from numpy.core._multiarray_umath import (
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "C:\Python37\lib\site-packages\numpy__init__.py", line 142, in
from . import core
File "C:\Python37\lib\site-packages\numpy\core__init__.py", line 71, in
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try git clean -xdf
(removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
1. Check that you are using the Python you expect (you're using C:\Python37\python.exe),
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy versions you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
If you're looking for a more seamless experience on windows, try using PyCharm or Anaconda which will automatically install numpy/scipy for you, rather than the standard python interpreter.

Library is not in Pycharm, even though i have already installed it

So i wanted to use the Quandl package to learn some data processing. I installed Quandl in the pycharm package, and it worked out pretty well.
import Quandl, math
and then, i use the Quandl to get some data from the internet
data = Quandl.get('some form of data')
But then when i tried to run the python script
bash-3.2$ python Regression.py
Traceback (most recent call last):
File "Regression.py", line 2, in <module>
import Quandl, math
ImportError: No module named Quandl
In my Pycharm interpreter, i have 4 different types:
-2.7.11 (/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7) I installed Quandl here
-3.5.1 (/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/bin/python3.5) I also installed it here
-2.6.9 (/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6) It has an error to install packaging tools
-/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 Permission denied for installing
When i tried to import Quandl in the terminal through python shell, i also retired an error
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Quandl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Quandl
I also tried the same thing for Simple CV, it also says that it's not in the module, even though I've already installed it both in 3.5 and 2.7.
from SimpleCV import Camera
cam = Camera()
while True:
img = cam.getImage()
img = img.binarize()
img.drawText("Hello World")
img.show()
bash-3.2$ python simplecv.py
Traceback (most recent call last):
File "simplecv.py", line 1, in <module>
from SimpleCV import Camera
ImportError: No module named SimpleCV
For installing 'pip', i also had an error installing it in the Pycharm terminal. I've already asked a question about it Installing pip in Pycharm 2016.3
Try to install it using pip2.7. I suspect that you are trying to execute the script with python3 (python command), however, your python interpreter in pyCharm is python2.7.
If you keep getting errors I suggest you to research a bit about virtualenvs, as it can help you had your several dependencies and interpreters easly organized by proyect. (PyCharm has support for virtualenvs)
When you invoke "python" in your console it launches the default Python interpreter (in your case Python 2.7.10). Looks like in PyCharm you selected different interpreter and installed packages on it. Make sure you use the same interpreter in PyCharm (Settings | Project | Project interpreter)

Importing wxPython fails in Maya

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

Categories