Enthought Canopy --- error in using sklearn - enthought

I just installed Enthought Canopy on an Imac Os 10.6.8.
I get an error message (appended below) when I try to test sklearn.
The error is ImportError: numpy.core.multiarray failed to import.
It looks like the wrong version of numpy is being used. I'm not sure how to fix.
Rich
mu51220:~ rscherl$ python
Enthought Canopy Python 2.7.3 | 32-bit | (default, Jun 14 2013, 18:24:40)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
from sklearn import datasets
/Library/Python/2.6/site-packages/numpy/random/init.py:87: RuntimeWarning: compiletime version 2.6 of module 'mtrand' does not match runtime version 2.7
from mtrand import *
RuntimeError: module compiled against API version 7 but this version of numpy is 6
Traceback (most recent call last):
File "", line 1, in
File "/Users/rscherl/Library/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/sklearn/init.py", line 32, in
from .base import clone
File "/Users/rscherl/Library/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/sklearn/base.py", line 10, in
from scipy import sparse
File "/Users/rscherl/Library/Enthought/Canopy_32bit/System/lib/python2.7/site-packages/scipy/sparse/init.py", line 182, in
from .csr import *
File "/Users/rscherl/Library/Enthought/Canopy_32bit/System/lib/python2.7/site-packages/scipy/sparse/csr.py", line 15, in
from .sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
File "/Users/rscherl/Library/Enthought/Canopy_32bit/System/lib/python2.7/site-packages/scipy/sparse/sparsetools/init.py", line 5, in
from .csr import *
File "/Users/rscherl/Library/Enthought/Canopy_32bit/System/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py", line 26, in
_csr = swig_import_helper()
File "/Users/rscherl/Library/Enthought/Canopy_32bit/System/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py", line 22, in swig_import_helper
_mod = imp.load_module('_csr', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import

I discovered that I had in my PYTHONPATH (as defined in my .profile)
/Library/Python/2.6/site-packages from where the wrong version of numpy was being picked up.
Eliminating this corrected the problem.

Related

PyCUDA -- problems importing pycuda.driver

Windows 10
Python 3.8
CUDA 11.5
I've installed what I believe to be a matching pycuda from this file:
pycuda-2021.1+cuda115-cp38-cp38-win_amd64.whl
This simple example fails
import pycuda.driver as drv
drv.init()
print("Detected {} CUDA devices".format(drv.Device.count()))
With this error:
Traceback (most recent call last):
File "C:/University of Arizona/weeds/tests/cuda-summary.py", line 5, in <module>
import pycuda.driver as drv
File "C:\Users\evan\AppData\Local\Programs\Python\Python38\lib\site-packages\pycuda\driver.py", line 65, in <module>
from pycuda._driver import * # noqa
ImportError: DLL load failed while importing _driver: The specified procedure could not be found.
NVCC is in my path
Adding os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin')) has no effect
The script works just fine on my Jetson Nano
Any ideas on how to get past this? I've searched and tried several solutions.
It is quite strange, but updating the Nvidia display driver fixed the issue for me.
But in my case there was no issue on my PC with the same versions of Windows, Python, CUDA and PyCuda. The issue appeared on the different Windows 10 machine, when launching the exe, packaged by PyInstaller. So, updating the display driver was the fix for this machine.

Can't launch ipython after El Capitan upgrade

Does anyone know how to undo the changes to paths and permissions wrought by upgrading to El Capitan. Specifically, it appears that OS X is now using the system python instead of my Canopy installation.
These look ok:
Michaels-Mac-mini:~ mellis$ which python
/Users/mellis/Library/Enthought/Canopy_64bit/User/bin/python
Michaels-Mac-mini:~ mellis$ which ipython
/Users/mellis/bin/ipython
But trying to launch ipython fails:
Michaels-Mac-mini:~ mellis$ ipython
Traceback (most recent call last):
File "/Users/mellis/bin/ipython", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/pyth on/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 576, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: ipython==0.11
A complete update of my installed Canopy packages including ipython seems to have fixed the problem.

scipy not compiling on Python 3.4

When importing scipy:
from scipy import signal
I get the errors:
Traceback (most recent call last):
File "F:\Desktop\Programming\Python\Sample Programs\src\butter.py", line 7, in <module>
from scipy import signal
File "C:\Python34\lib\site-packages\scipy\signal\__init__.py", line 280, in <module>
from .bsplines import *
File "C:\Python34\lib\site-packages\scipy\signal\bsplines.py", line 12, in <module>
from scipy.special import comb, gamma
File "C:\Python34\lib\site-packages\scipy\special\__init__.py", line 601, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.`
I am running Eclipse on windows 7. I installed scipy successfully using
pip3.4 install "scipy-0.16.0rc1-cp34-none-win32.whl"
Can you tell me how I can get scipy to work with this simple program on Windows 7?
As mentioned prior, the easiest way to get SciPy running on windows is to simply download the Anaconda distribution. Be sure to obtain the version you want. It works out of the box. Plus you get Jupyter/IPython Notebook which is a really cool interactive GUI interface. It's almost like working in Matlab!
http://continuum.io/downloads

py2app crashes with PIL errors on earlier versions of OS X

A similar question was asked before by someone else: https://stackoverflow.com/questions/23600028/py2app-app-crashes-on-earlier-mac-os-x-versions
I have an app that runs fine on my machine (OSX 10.9.4), but when I move it to another machine running 10.7.5, the app crashes on start up. I get the following messages in console:
Traceback (most recent call last):
File "/PATH_TO_APP/APP.app/Contents/Resources/__boot__.py", line 3
_recipes_pil_prescript(['Hdf5SubImagePlugin', 'FitsStubImagePlugin', 'SunImagePlugin', 'GbrImagePlugin', 'Jpeg2KImagePlugin', 'MicImagePlugin', 'FpxImagePlugin', ImImagePlugin', ...
File "/PATH_TO_APP/APP.app/Contents/Resources/__boot__.py, line 3
from PIL import Image
File "PIL/Image.pyc", line 62, in <module>
File "PIL/_imaging.pyc", line 14, in <module>
File "PIL/_imaging.pyc", line 10, in __load
ImportError: dlopen(/PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so, 2): Symbol not found: ___sincos_stret
Referenced from /PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so
Expected in: /usr/lib/libSystem.B.dylib
in /PATH_TO_APP/APP.app/Contents/Resources/lib/python2.7/lib-dynload/PIL/_imaging.so
Earlier, to get around this error, I just uninstalled pillow. I'm not sure why pillow libraries were being added to the app to begin with, since I didn't think I was using it. But now, when attempting this workaround, I get another error:
Traceback (most recent call last):
File "/PATH_TO_APP.app/APP.app/Contents/Resources/__boot__.py", line 384, in <module> _recipes_pil_prescript([])
File "/PATH_TO_APP.app/APP.app/Contents/Resources/__boot__.py", line 344, in _recipes_pil_prescript from PIL import Image
File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 62, in <module>
ImportError cannot import name _imaging
Apparently I'm using PIL now somehow. My script imports the following:
from __future__ import division
import easygui as eg
import os, zlib, re, datetime, getpass, tkMessageBox, sys
import zipfile as z
import Tkinter as tk
from tkFileDialog import askdirectory
from optparse import OptionParser
Here's my setup.py:
from setuptools import setup
APP = ['zipperscript.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'excludes': ['']}
setup(
app=APP,
name="Zipperscript_HI_50",
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
version="Hawaii branch 4.0.50"
)
I'm not sure that the OS version is causing the problem, but that's my theory right now. I'm not sure how to proceed. Any help or suggestions are greatly appreciated.
I encountered a similar problem while using buildout on Mac OS 10.8.5. It seems that the pre-compiled packages available on Pypi have been compiled on newer versions of OS X and unfortunately insufficiently tested on older versions.
The solution is to install pillow from source instead. Download the source, and run pip install your_downloaded_file. You may need to install dependencies such as libjpeg and zlib beforehand.
After doing this I do not encounter the errors anymore and have pillow version 5.4.0 installed.

Error using pygraphviz on Mac OSX Lion

After some struggle installing pygraphviz on Mac OSX Lion ([sudo] easy_install pygraphviz) I've tried to use it, but it crashes when I import it. Here you can see the error.
Any idea to solve it? Do I should install another aux library...?
>>> import pygraphviz
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/__init__.py", line 54, in <module>
from agraph import AGraph, Node, Edge, Attribute, ItemAttribute
File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/agraph.py", line 19, in <module>
import graphviz as gv
File "/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/graphviz.py", line 7, in <module>
import _graphviz
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/_graphviz.so, 2): Symbol not found: _Agundirected
Referenced from: /Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pygraphviz/_graphviz.so
Expected in: dynamic lookup