?
Solved

Problem with SciPy

Posted on 2011-09-09
19
Medium Priority
?
1,554 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 680 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
New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

 

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 320 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Plenty of writing has gone on the web trying to compare Python with other competitive programming languages and vice versa. However, not much has been put into a wholistic perspective. This article should help you decide whether to adopt Python as a…
Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Suggested Courses

770 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