#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    7
    Rep Power
    0

    A problem about import


    Hi,
    I am quite new programmer with Python. I am using Eclipse as IDE. What I want to do is to import scipy lib into my program.

    what I have done is
    1 I have set the PYTHONPATH where my scipy lib is
    2 add the import sentence into my program

    then come out this error:
    Code:
    could not import scipy.optimize.leastsq
    Traceback (most recent call last):
      File "/home/deathlypest/workspace/Robotics/helper.py", line 5, in <module>
        import scipy.interpolate as sp 
      File "/home/deathlypest/workspace/scipy/scipy/__init__.py", line 120, in <module>
        raise ImportError(msg)
    ImportError: Error importing scipy: you cannot import scipy while
            being in scipy source directory; please exit the scipy source
            tree first, and relaunch your python intepreter.
    I have browse through the internet and find no solution.
    Is there anyone can help with that? fully appreciation thanks
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    Ooh, strange things can occur when python imports standard modules from the current directory. This part of the error message is relevant:
    Code:
    ImportError: Error importing scipy: you cannot import scipy while
            being in scipy source directory; please exit the scipy source
            tree first, and relaunch your python intepreter.
    Put your new code into ~/myProjects , change direcotry to ~/myProjects , and run python from that directory.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Ooh, strange things can occur when python imports standard modules from the current directory. This part of the error message is relevant:
    Code:
    ImportError: Error importing scipy: you cannot import scipy while
            being in scipy source directory; please exit the scipy source
            tree first, and relaunch your python intepreter.
    Put your new code into ~/myProjects , change direcotry to ~/myProjects , and run python from that directory.
    Sorry haven't understood what you have said. My scipy modular is not under the same directory with my codes. So I am confused by the error. And what means "put your new code into ~/myprojects"

    Thanks a lot

IMN logo majestic logo threadwatch logo seochat tools logo