[Python] Pip installation of scipy.optimize (or scipy correctly(?))

Discussão em 'Python' iniciado por Stack, Fevereiro 9, 2025.

  1. Stack

    Stack Membro Participativo

    After uninstalling Anaconda to stop problems with Jupyter notebook kernels, I am trying to run a file which requires

    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib.colors import LogNorm
    from matplotlib import animation
    from IPython.display import HTML
    from autograd import elementwise_grad, value_and_grad
    from scipy.optimize import minimize
    from collections import defaultdict
    from itertools import zip_longest
    from functools import partial


    and getting this message:

    ---------------------------------------------------------------------------
    ImportError Traceback (most recent call last)
    <ipython-input-2-29781769facb> in <module>()
    10
    11 from autograd import elementwise_grad, value_and_grad
    ---> 12 from scipy.optimize import minimize
    13 from collections import defaultdict
    14 from itertools import zip_longest

    c:\python27\lib\site-packages\scipy\__init__.py in <module>()
    59 __all__ = ['test']
    60
    ---> 61 from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
    62
    63 from numpy import show_config as show_numpy_config

    ImportError: cannot import name NUMPY_MKL


    I tried installing scipy.optimize:

    C:\Users\Toni>pip install scipy.optimize
    Collecting scipy.optimize
    Could not find a version that satisfies the requirement scipy.optimize (from versions: )
    No matching distribution found for scipy.optimize


    I'm using Windows 10 on a 64-bit computer, and python 2.7.13.

    I did try the following:

    >C:\Users\Toni>pip install scipy
    Requirement already satisfied: scipy in c:\python2/\lib\site-packages
    Requirement already satisfied: numpy>=1.8.2 in c:\python2/\lib\site-package (from scipy)


    PROGRESS NOTES:

    OK... It seems as though scipy may have been incorrectly installed (following the lead from the first answer)... So I uninstall it, and then try...

    pip install scipy

    failed with error code 1 in c:\users\toni\appdata\local\temp\pip-build-vnjyae\scipy


    which sends me here, and later on here, but not so fast, first stop here with the conundrum of which one to choose:

    NumPy, a fundamental package needed for scientific computing with Python.
    Numpy+MKL is linked to the Intel® Math Kernel Library and includes required DLLs in the numpy.core directory.
    numpy‑1.11.3+mkl‑cp27‑cp27m‑win32.whl
    numpy‑1.11.3+mkl‑cp27‑cp27m‑win_amd64.whl
    numpy‑1.11.3+mkl‑cp34‑cp34m‑win32.whl
    numpy‑1.11.3+mkl‑cp34‑cp34m‑win_amd64.whl
    numpy‑1.11.3+mkl‑cp35‑cp35m‑win32.whl
    numpy‑1.11.3+mkl‑cp35‑cp35m‑win_amd64.whl
    numpy‑1.11.3+mkl‑cp36‑cp36m‑win32.whl
    numpy‑1.11.3+mkl‑cp36‑cp36m‑win_amd64.whl
    numpy‑1.13.0+mkl‑cp27‑cp27m‑win32.whl
    numpy‑1.13.0+mkl‑cp27‑cp27m‑win_amd64.whl
    numpy‑1.13.0+mkl‑cp34‑cp34m‑win32.whl
    numpy‑1.13.0+mkl‑cp34‑cp34m‑win_amd64.whl
    numpy‑1.13.0+mkl‑cp35‑cp35m‑win32.whl
    numpy‑1.13.0+mkl‑cp35‑cp35m‑win_amd64.whl
    numpy‑1.13.0+mkl‑cp36‑cp36m‑win32.whl
    numpy‑1.13.0+mkl‑cp36‑cp36m‑win_amd64.whl


    And here is the key (probably):

    Typing python on the cmd prompt I get:

    Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win 32


    So from Python 2.7, I need the 27 version, and from win 32 I have to disregard the fact that I have a 64-bit computer. So clear...

    Continue reading...

Compartilhe esta Página