I'm trying to upload the curve_fit from scipy.optimize to fit an exponential function to some data I have generated. My code looks like:
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit
When I run the code, I get the following error:
ImportError: DLL load failed: The specified module could not be found.
I have scipy in an Anaconda folder on my computer, and I'm 80% sure I installed it. How do I fix this error? (Or if you have a better way of fitting an exponential function to data, I'm all ears)
Thanks!
edit: Here is the full error:
Traceback (most recent call last):
File "C:\Users\Casey\Documents\Python\Perc_MatPlot3.py", line 10
from scipy.optimize import curve_fit
File "C:\Users\Casey\Anaconda\Lib\site-packages\scipy\optimize\__init__.py", line 146
from .optimize import *
File "C:\Users\Casey\Anaconda\Lib\site-packages\scipy\optimize\optimize.py", line 35
from .linesearch import (line_search_BFGS, line_search_wolfe1,
File "C:\Users\Casey\Anaconda\Lib\site-packages\scipy\optimize\linesearch.py", line 16
from scipy.optimize import minpack2
ImportError: DLL load failed: The specified module could not be found.
I encountered the error
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
when using cgoehlke's "Unofficial Windows Binaries for Python Extension Packages" for SciPy with a pip3-installed NumPy, overlooking this note:
Many binaries depend on NumPy-1.9+MKL and ...
Their NumPy provides the missing DLLs / modules.
I've run into several problems like this recently when trying to use pyplot and scipy. I have Anaconda 2.7, 32bit running on Windows 7 x64
I just encountered this exact error whilst trying to use curve_fit. I downloaded the 'superpack' from sourceforge: http://sourceforge.net/projects/scipy/
Running this installer fixed the error and didn't affect any other part of my python environment.
I was suffering from exactly the same problem.
from scipy.optimize import minpack2
I reinstalled numpy and MLK but still got this error on Pycharm. I directly update my python to 3.6 and now the problem is solved.
During the procedure, use
conda install python=3.6
Since
conda update python
showed me that I already have the 3.5.2, which means conda update failed to update from 3.5 to 3.6 and it is supposed to be capable of upgrading from versions like 3.5.1-->3.5.2 I think.
Hope this could help. Plus, remember to reset the environment after the update.
Not sure if this is an answer for you, because this error can mean so many things... I've been there...
I just had the same error (also while loading Scipy optimize) just 10 minutes ago with a fresh install of Miniconda for Python 3.3 on a Vista x64 machine. Somehow it failed to add the main Python directory to the Windows PATH (and I'm pretty sure I didn't uncheck the box for it at the end of the installation).
I did the same procedure on some XP and Windows 7 machines earlier this week without any problems, so i caught me a bit by surprise.
If you have no other Python installation on your machine, you can check if running 'python' (type win-key + r, or do it from command prompt) works. If it doesn't, simply add your main installation directory (where python.exe is located) to your PATH variable.
If this doesn't work you could use Dependency Walker to check which DLL the error message is actually about, and then see if that DLL is present somewhere within your PATH or PYTHONPATH.
I have had the same DLL error when multiple versions of the same DLL were compiled with different compilers and the required version wasn't found first. If removing a version (the program it came with) isn't an option, changing the order of your PATH variable can help.
This is most likely you installed 32-bit Python but 64-bit libraries or vice versa.
You need to remove Python and reinstall correct python.
https://www.python.org/download/
Here you can download Python.
Remember you python libraries should be the same 32bit or 64bit as the one of Python.
Related
I'm doing some scientific computation in python, and recently switched away from Anaconda since it doesn't yet support python 3.10 (which has some new features I'd like to use). I am now running on python version 3.10.9. I have a pipenv virtual environment set up for this, and in it I've got numpy version 1.23.5 installed. (Trying to upgrade to a newer version fails with a bunch of errors -- if upgrading numpy ends up being necessary I'll need to open a new question to ask about how to get that working.)
Everything initially seems to be working fine, until I try to run a parallelized numpy computation. At that point, I get the error DLL load failed while importing _multiarray_umath: The specified module could not be found. Here's the associated traceback:
Traceback (most recent call last):
File "C:\Users\charles\.virtualenvs\pipenv-WB8juvy1\lib\site-packages\numpy\core\__init__.py", line 23, in <module>
from . import multiarray
File "C:\Users\charles\.virtualenvs\pipenv-WB8juvy1\lib\site-packages\numpy\core\multiarray.py", line 10, in <module>
from . import overrides
File "C:\Users\charles\.virtualenvs\pipenv-WB8juvy1\lib\site-packages\numpy\core\overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
I can import numpy just fine, and I can use various functions from numpy without issue as well. I only get problems when I specifically want to do some parallelized computations. At that point my console gets flooded with this error (as far as I can tell, it's printing nearly exactly the same thing over and over, presumably once for every worker that it tried to launch).
The following text is also included in the error message:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.10 from "C:\Users\charles\.virtualenvs\pipenv-WB8juvy1\Scripts\python.exe"
* The NumPy version is: "1.24.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
While this looks pretty promising, I've read through the documentation on that page and nothing seems to be addressing the particular issue I'm running into here.
Additional details about my setup: The virtual environment was set up with pipenv, using the --site-packages flag (as I don't seem to be able to properly install PyQt5 in the virtual environment, so I'm just sourcing it from the system). I've got numpy installed in both my system's site-packages - that is version 1.24.1 (which checks out with the error messages) - and in the virtual environment's site packages (I didn't explicitly install it there, it was installed as a dependency; the virtual version is 1.23.5). Uninstalling numpy from the system site packages does not fix the issue.
I've also tried completely deleting the virtual environment and reinstalling it from the pipfile, but that also doesn't fix the issue. The version of numpy which is installed in the virtual environment does indeed have a DLL in its .lib folder, so it's not just missing. As far as I can tell there's nothing weird about my path; just in case I tried manually adding the .lib folders where the DLLs live to the path. I added both the virtual and system site packages to the path, and tried sourcing them in various different orders, to no avail.
I'm kinda at the end of my ability to troubleshoot this at this point, hence this request for help. In the meantime I'm resorting to doing all of my computations serially, but (as you might imagine) this is very slow and not very sustainable for the long term. If nobody can help me fix this, I'm going to have to just go back to Anaconda and give up on features from the newer python versions until they support them. (Or maybe I can try working without a virtual environment, but I've messed up systems pretty badly that way before and I'm kind of loathe to take that approach).
In Power BI, I am trying to import a CSV-file that's stored in an AWS S3 bucket. I used the script I found here to import the data, but I keep getting this error:
Details: "ADO.NET: Python script error. <pi>C:\Users\MyName\anaconda3\envs\PowerBI\lib\site-packages\numpy\__init__.py:143: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service from . import
_distributor_init Traceback (most recent call last): File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib File "C:\Users\MyName\anaconda3\envs\PowerBI\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies) ImportError: Unable to import required dependencies: numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "C:\Users\MyName\anaconda3\envs\PowerBI\python.exe" * The NumPy version is: "1.20.1"
and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: The specified module could not be found.
</pi>"
Anyone any ideas? I already tried lots of things myself, like:
installing a clean Anaconda virtual environment with the required libraries
remove/install numpy and setuptools as described here
Unfortunately nothing works, I keep getting the same error. Does anyone know what to do? Can it be that the Python and numpy version are not compatible? If yes, how can I find out what versions I should use that are compatible (I tried figuring this out but could not find any information)?
The NumPy version is: "1.20.1"
Currently the service supports NumPy 1.18.4.
Make sure all your modules, and version of python match the docs located here: https://learn.microsoft.com/en-us/power-bi/connect-data/service-python-packages-support
I did extensive research in the past few days and figured it out:
Anaconda is not a good option to use in combination with Power BI because you need to be able to open Power Bi from the command prompt (which I can't), see this acticle
Instead of using Anaconda I installed Python 3.8.7 locally (64-bit version) and installed the required packages
To avoid any conflicts between Python versions I deleted all other local Python installations (I did not delete Anaconda's Python versions)
Then I opened Power BI from the start menu, cleared the cache in Power BI options & settings - Data Load (see image) and then closed Power BI again.
Then I opened Power BI again from the start menu and ran my Python script... it worked!
I want to call Python modules or user-defined functions/scripts I built in python through Matlab. I'm aware of many of the things I need to cover before something like this is possible, I'll make a list of everything I've done so far.
Created Virtual Environment with Anaconda and istalled all the dependencies I needed. Python version 3.5.2
Ran the scripts using PyCharm and all runs good/as expected.
When running pyversion(mypath) in Matlab, though it appears "loaded: 1", I can't call anything on the site-packages module. For example, I can't even call something like numpy (py.importlib.import_module('numpy')) because I get the following error:
Python Error: ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
I've verified everything I could so far. Python and Matlab (2016a) are both 64 bits. Although, I can run this small snippet of code with the expected outcome:
T = 'MATLAB(R) is a high-level language'
wrapped = py.textwrap.wrap(T);
whos wrapped
Since I can execute everything properly from PyCharm, and I can't from Matlab's side, I'm wondering if there's any restriction to enable from Matlab or Anaconda (in the configuration).
Is there a setting in the configuration of Anaconda that is maybe not allowing me to do this? Or is this an issue within Matlab? I'm not sure, I'm clueless.
I had a working SCIP installation on Python using the following thread:
SCIP Python Installation Issue Windows with pip
Now I have a new laptop and tried to re-install SCIP again but it does not work (I tried on several machines with the identical result). The software versions have changed so I refer to the new versions below.
Installation (Environment):
OS: Windows 10
Anaconda Version 5.0.1| Release Date: October 25, 2017; Python 3.6 (64 bit)
PyCharm, 2017.3 (Community Edition)
Library PySCIPOpt (pip install pyscipopt)
Unpacked the files from SCIPOPTDIR.rar in directory C:\SCIPOPT
Set the environment variables:
Added the Variable SCIPOPTDIR with the Value of the installation directory (i.e. C:\SCIPOPT)
Added in the PATH Variable the entry %SCIPOPTDIR%\lib
Error Message:
File "C:/Users/i070009/PycharmProjects/OptimizationModels/RunTestOfSCIPLibrary.py", line 1, in
from pyscipopt import Model, quicksum
ModuleNotFoundError: No module named 'pyscipopt'
If I use a jupyter Notebook (from pyscipopt import Model, quicksum) I get the following error message:
ImportError Traceback (most recent call last)
in ()
----> 1 from pyscipopt import Model, quicksum
C:\ProgramData\Anaconda3\lib\site-packages\pyscipopt__init__.py in ()
1 # export user-relevant objects:
2 from pyscipopt.Multidict import multidict
----> 3 from pyscipopt.scip import Model
4 from pyscipopt.scip import Branchrule
5 from pyscipopt.scip import Conshdlr
ImportError: DLL load failed: The specified module could not be found.
My guess is that the module is not found but since I added the PATH variables (and it worked on my old laptop) I’m puzzled why it does not work.
It might be a really simple problem. I’m just not seeing it! Thanks for any help on this topic!
This is already handled here: https://github.com/SCIP-Interfaces/PySCIPOpt/issues/110
One needs to make sure that the bin directory is available in the PATH on Windows so both the binary as well as the dll/lib are found during installation and execution of PySCIPOpt.
I need to install and use the Python NumPy module (and then later the Pandas module) in order to process heavy data in Python.
I downloaded and installed ENTHOUGHT, but it wasn't what I wanted all that extra clutter of extra modules (which defeats the purpose of importing Python modules only as needed), but the uninstall did not work properly (i.e. it left garbage folders and ENTHOUGHT remnants all over my computer).
I have tried installing NumPy via EASY_INSTALL and PIP (two package managers if I understand correctly) - but with no success. Every time I try to run my program, I get the error: "no module named numpy".
I have searched the questions here and have tried to alter my ENVIRONMENT VARIABLE as per the following video, but again, no success:
https://www.youtube.com/watch?v=ddpYVA-7wq4
C:\Python34
...still the same error!
I downloaded Anaconda (with all its extra clutter and installed, but I don't like the development environment - I want my Vanilla Python IDLE to run Vanilla NumPy with no extra clutter modules...) and when I tried to again install Numpy I received a message that it was already installed with a path to:
C:\users\yoni\anaconda3\lib\site-packages
....so I ALSO added this PYTHONPATH to the ENVIRONMENT VARIABLE in hopes that it would now recognize where the NumPy installation was (currently with Anaconda3 - but I hoped to be able to import NumPy to my vanilla Python IDLE):
C:\Python34;C:\users\yoni\anaconda3\lib\site-packages
I don't find a clear answer - I see others have the same problem, and nothing is working for me. How can I finish this installation of NumPy so that it works for me when I do a simple import of module?
This is a temporary solution until you can resolve your path issue.
It will be environment specific.
import sys
sys.path.append('C:\users\yoni\anaconda3\lib\site-packages[PackageName]')
import PakcageName