Solved

Problem with SciPy

Posted on 2011-09-09
19
1,423 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
  • 11
  • 5
  • 3
19 Comments
 
LVL 28

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
 

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 28

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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 28

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 28

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 28

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Example of using CouchDB with Flask 2 176
Cannot find cx_Oracle Version 4 225
Python algorithm 20 135
Using bootstrap with french text 13 75
This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
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 …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now