Solved

Problem with SciPy

Posted on 2011-09-09
19
1,495 Views
Last Modified: 2012-05-12
Hi

I am trying to use the SciPy package. I have installed it and had no obvious problems. However, when I try the following:

 import scipy.integrate as spint

I get the following error

 File "C:\Python32\lib\site-packages\scipy\integrate\__init__.py", line 7, in <module>
    from .quadrature import *
  File "C:\Python32\lib\site-packages\scipy\integrate\quadrature.py", line 5, in <module>
    from scipy.special.orthogonal import p_roots
  File "C:\Python32\lib\site-packages\scipy\special\__init__.py", line 9, in <module>
    from ._cephes import *
ImportError: DLL load failed: The specified module could not be found.

Specifically, I am trying to use the simps function but I am getting nowhere. Can anybody help?

Issac
0
Comment
Question by:IssacJones
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 5
  • 3
19 Comments
 
LVL 29

Accepted Solution

by:
pepr earned 170 total points
ID: 36508782
What version of Windows you have? The 32-bit or the 64-bit?  It seems that the SciPy is not installed correctly for your system.  I will try later on my computer.

Can you post the tiniest possible snippet that also causes the error?
0
 

Author Comment

by:IssacJones
ID: 36509029
It is a 64-bit. This is the link I use from http://www.scipy.org/Download

Windows 64 bit unofficial releases

Christoph Gohlke has put together an impressive collection of Windows binary installers of recent versions of scientific packages for Python, including amd64 versions of Numpy and Scipy compiled against Intel's MKL, and SciKits:

http://www.lfd.uci.edu/~gohlke/pythonlibs


I am going to try and re-install and see what happens. HOWEVER, I also note that there may be something wrong with installing the non-64 bit because I am told that version 2.6 of Python needs to exist on the system but the current version of Python which can be downloaded is 2.7 (no?)

Hope you can help.

Issac
0
 

Author Comment

by:IssacJones
ID: 36509045
p.s. It is the line

 import scipy.integrate as spint

which fails.

I think you are right, there is something wrong in the installation. I will be interested to learn if it can be reproduced.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:IssacJones
ID: 36509077
sorry, actually it is the following line that causes the problem:

Traceback (most recent call last):
  File "C:\Users\David\Code\combinations4.py", line 38, in <module>
    totalintegral = scipy.integrate.simps( x, y )
NameError: name 'scipy' is not defined
0
 
LVL 6

Expert Comment

by:LeeeRussell
ID: 36509081
You say that you've installed it with no obvious problems.  How did you install it?  I notice from the SciPy website that they don't provide a standard Windows installer for Python 3.2.  Did you build the source yourself?
0
 
LVL 6

Expert Comment

by:LeeeRussell
ID: 36509086
Sorry, I wrote the previous comment whilst you were writing yours.

Python 2.6 can be downloaded here:

http://www.python.org/download/releases/2.6/
0
 

Author Comment

by:IssacJones
ID: 36509439
I'm very puzzled still!

I have downloaded Python 2.6 (thanks Lee) but still using Python 3.2

If I type import scipy at the command prompt and press enter there is no problem.

However, if I type import scipy.integrate I get errors!

This should work shouldn't it? (see http://docs.scipy.org/doc/scipy/reference/integrate.html)

Any ideas?

Can anybody reproduce the problem?

Issac
0
 

Author Comment

by:IssacJones
ID: 36509444
I have just found the following link but there is no answer to the problem:

http://stackoverflow.com/questions/4642600/issue-with-importing-scipy-integrate-or-scipy-integrate-quad
0
 
LVL 29

Expert Comment

by:pepr
ID: 36509524
Traceback (most recent call last):
  File "C:\Users\David\Code\combinations4.py", line 38, in <module>
    totalintegral = scipy.integrate.simps( x, y )

Open in new window


When using "import scipy.integrate as spint", you actually make the alias to the scipy.integrate namespace.  Or you have to "import scipy" or "import scipy.integrate" for you command, or you have to change your command to:

    totalintegral = spint.simps( x, y )

Open in new window


0
 

Author Comment

by:IssacJones
ID: 36509563
I have tried the following at the command line and still get an error message:

Python 3.2.1 (default, Jul 10 2011, 20:02:51) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import scipy.integrate
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import scipy.integrate
  File "C:\Python32\lib\site-packages\scipy\integrate\__init__.py", line 7, in <module>
    from .quadrature import *
  File "C:\Python32\lib\site-packages\scipy\integrate\quadrature.py", line 5, in <module>
    from scipy.special.orthogonal import p_roots
  File "C:\Python32\lib\site-packages\scipy\special\__init__.py", line 9, in <module>
    from ._cephes import *
ImportError: DLL load failed: The specified module could not be found.
>>>

HOWEVER, if I don't if I just import scipy i.e.

>>> import scipy
>>> 

Any ideas?

0
 
LVL 29

Expert Comment

by:pepr
ID: 36509673
I see, I am kidding.  The scipy has the form of a package.  The integrate is just a subpackage.  I have no answer yet.  I was able to simulate the same situation after installing the numpy and scipy on my machine.
0
 
LVL 29

Expert Comment

by:pepr
ID: 36509680
I do not have a time to experiment just now.  Have a look at working with packages and subpackages http://docs.python.org/py3k/tutorial/modules.html#packages
0
 

Author Comment

by:IssacJones
ID: 36509887
I've now installed on another machine Python 2.7 and I still get the same problem!!!

This is the error code I get:

Traceback (most recent call last):
  File "C:\Documents and Settings\Issac\My Documents\Dropbox\Python\Code\combinations4.py", line 36, in <module>
    totalintegral = sp.integrate.simps( x, y )
AttributeError: 'module' object has no attribute 'integrate'

Note that I used

import scipy as sp

at the top of the file.

Am I doing something really obviously wrong???

Issac
0
 

Author Comment

by:IssacJones
ID: 36509893
Hi pepr

To clarify, you have seen exactly the same problem?

Issac
0
 
LVL 6

Assisted Solution

by:LeeeRussell
LeeeRussell earned 80 total points
ID: 36509948
I would expect the error you are getting.

You are importing the module scipy.integrate and naming it sp.

If you then use sp.integrate, you are effectively trying to use a module called scipy.integrate.integrate.

Try using either scipy.integrate.simps()  OR sp.simps()

Either of these should work.
0
 
LVL 29

Expert Comment

by:pepr
ID: 36510055
Yes, I can confirm that.  But I have never used SciPy before, and I actually do not know what I am doing.  I also do not know whether it is installed correctly.  I did use the Gohlke's NumPy and SciPy 64 bit (http://www.lfd.uci.edu/~gohlke/pythonlibs/).

c:\tmp>python3
Python 3.2.1 (default, Jul 10 2011, 20:02:51) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> scipy.integrate.simps()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'integrate'
>>> import scipy.integrate
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python32\lib\site-packages\scipy\integrate\__init__.py", line 7, in <module>
    from .quadrature import *
  File "c:\Python32\lib\site-packages\scipy\integrate\quadrature.py", line 5, in <module>
    from scipy.special.orthogonal import p_roots
  File "c:\Python32\lib\site-packages\scipy\special\__init__.py", line 9, in <module>
    from ._cephes import *
ImportError: DLL load failed: Uvedený modul nebyl nalezen.
>>>

Open in new window


And the same with Python 2.7

c:\tmp>python
Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> scipy.integrate.simps()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'integrate'
>>> import scipy.integrate
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python27\lib\site-packages\scipy\integrate\__init__.py", line 7, in <module>
    from quadrature import *
  File "c:\Python27\lib\site-packages\scipy\integrate\quadrature.py", line 5, in <module>
    from scipy.special.orthogonal import p_roots
  File "c:\Python27\lib\site-packages\scipy\special\__init__.py", line 9, in <module>
    from _cephes import *
ImportError: DLL load failed: Uvedenr modul nebyl nalezen.
>>>

Open in new window


Actually, the problem is probably with the _cephes and the errors can be related.  When importing the module, the packages are initialized.  The initialization failed.
0
 

Author Comment

by:IssacJones
ID: 36510556
Hi pepr

I have had some success. If I use

from scipy import integrate

Then I can use

integrate.simpsn

can you do the same?

Issac
0
 

Author Comment

by:IssacJones
ID: 36511105
Hi guys

Okay, I have managed to get it working. What I did was uninstall all the 64 bit stuff and installed the 32 bit versions. The python from ww.python.org and numpy and scipy from http://www.lfd.uci.edu/~gohlke/pythonlibs. In doing so, I can use

import scipy.integrate as spi

and then

spi.simpsn( etc.

Thanks for all your help. I'll allocate points shortly.

Issac
0
 

Author Closing Comment

by:IssacJones
ID: 36511170
Thanks guys
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question