I have installed Python 2.5.4, Numpy 1.5.0 win32, Matplotlib 1.0.0 win32, pywin32 218. Still not able to plot graphs in Python. Here is the error I am getting :
import pylab
File "C:\Python25\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python25\lib\site-packages\matplotlib\pylab.py", line 216, in <module>
from matplotlib import mpl # pulls in most modules
File "C:\Python25\lib\site-packages\matplotlib\mpl.py", line 1, in <module>
from matplotlib import artist
File "C:\Python25\lib\site-packages\matplotlib\artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "C:\Python25\lib\site-packages\matplotlib\transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: DLL load failed: The specified module could not be found.
Please kindly help..
(I found this answer from a video: http://www.youtube.com/watch?v=xmvRF7koJ5E)
Download msvcp71.dll and msvcr71.dll from the web.
Save them to your C:\Windows\System32 folder.
Save them to your C:\Windows\SysWOW64 folder as well (if you have a 64-bit operating system).
Now try running your code file in Python and it will load the graph in couple of seconds.
I had the same issue with importing matplotlib.pylab with Python 3.5.1 on Win 64. Installing the Visual C++ Redistributable für Visual Studio 2015 from this links: https://www.microsoft.com/en-us/download/details.aspx?id=48145 fixed the missing DLLs.
I find it better and easier than downloading and pasting DLLs.
For Windows 10 x64 and Python:
Open a Visual Studio x64 command prompt, and use dumpbin:
dumpbin /dependents [Python Module DLL or PYD file]
If you do not have Visual Studio installed, it is possible to download dumpbin elsewhere, or use another utility such as Dependency Walker.
Note that all other answers (to date) are simply random stabs in the dark, whereas this method is closer to a sniper rifle with night vision.
Case study 1
I switched on Address Sanitizer for a Python module that I wrote using C++ using MSVC and CMake.
It was giving this error: ImportError: DLL load failed: The specified module could not be found
Opened a Visual Studio x64 command prompt.
Under Windows, a .pyd file is a .dll file in disguise, so we want to run dumpbin on this file.
cd MyLibrary\build\lib.win-amd64-3.7\Debug
dumpbin /dependents MyLibrary.cp37-win_amd64.pyd which prints this:
Microsoft (R) COFF/PE Dumper Version 14.27.29112.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file MyLibrary.cp37-win_amd64.pyd
File Type: DLL
Image has the following dependencies:
clang_rt.asan_dbg_dynamic-x86_64.dll
gtestd.dll
tbb_debug.dll
python37.dll
KERNEL32.dll
MSVCP140D.dll
VCOMP140D.DLL
VCRUNTIME140D.dll
VCRUNTIME140_1D.dll
ucrtbased.dll
Summary
1000 .00cfg
D6000 .data
7000 .idata
46000 .pdata
341000 .rdata
23000 .reloc
1000 .rsrc
856000 .text
Searched for clang_rt.asan_dbg_dynamic-x86_64.dll, copied it into the same directory, problem solved.
Alternatively, could update the environment variable PATH to point to the directory with the missing .dll.
Please feel free to add your own case studies here! I've made it a community wiki answer.
Installing the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 worked for me with a similar problem, and helped with another (slightly different) driver issue.
Since Python 3.8, it is possible that Dependencies or dumpbin /dependents reports no dependency issue, but one still gets the error "The specified module could not be found". This is because the PATH variable is no longer used for resolving DLLs of binary modules!
The solution is to use os.add_dll_directory:
import os
os.add_dll_directory(r"C:\path\to\your\dll\directory")
import your_module
Quick note:
Check if you have other Python versions, if you have removed them, make sure you did that right. If you have Miniconda on your system then Python will not be removed easily.
What worked for me: removed other Python versions and the Miniconda, reinstalled Python and the matplotlib library and everything worked great.
I installed vc++ which solved this problem.
Reinstall the related packages.
I have the same issue with numpy. I first uninstalled it:
pip uninstall numpy
and then installed again
pip install numpy==1.20.1
I needed that specific version. If you want to install other numpy versions, you may ignore ==1.20.1.
Also, during the installation, I received errors such as
statsmodels 0.12.2 requires patsy>=0.5, which is not installed.
I installed those missing prerequisites as well. e.g.,
pip install patsy
I just uninstalled my current numpy and installed a wheel numpy from this link.
This has solved my issue. I guess we shoudn't use dll from random source.
This might be issue of missing Microsoft Visual C++ Redistributable packages for Visual Studio 2015, 2017, 2019, and 2022 in your machine. Use the following link to download the distributable and install it in your machine.
VC_redist.x64.exe
For more: Microsoft Visual C++ Redistributable Latest Supported Downloads
I've been through this error and what I found after a lot of investigation:-
issue was in Opencv==4.5.1 build from source with cuda and flag cuda_with_fast_math=on
I just rebuild OpenCV and disable
cuda_with_fast_math
make sure that the shared library builded with cv version matched your current version
and it works for me.
Related
I am currently trying to pip install tensorflow, which works but after I install it, and then import it into my python module via import tensorflow as tf I get following error message:
ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that
these DLLs be installed in a directory that is named in your %PATH% environment
variable. You may install these DLLs by downloading "Microsoft C++ Redistributable
for Visual Studio 2015, 2017 and 2019" for your platform from this URL:
https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads
I installed the msvcp140_1.dll and put it into C:\Users\User\AppData\Local\Programs\Python\Python37 which is contained in my path environment variable.
As you can see I am using Python 3.7 as 3.8 is not supported by tensorflow.
Any ideas how to fix this?
You can find msvcp140.dll in your %windows%/System32 folder, once you installed VC++ DIST for VS 2015, for msvcp140_1.dll you need to goto this page
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
and in the section :Visual Studio 2015, 2017 and 2019, pick the correct package with the arch of your PC.
Just click this link https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads Then install
x64: vc_redist.x64.exe
and restart your pc.
I recommend you this setup tutorial, it works on my computer. And you need python 3.6 for Tensorflow instead of 3.7.
https://github.com/jeffheaton/t81_558_deep_learning/blob/master/manual_setup.ipynb
In my case, Downloading Visual C++ from the url below works.
https://support.microsoft.com/en-gb/help/2977003/the-latest-supported-visual-c-downloads
Problem
I am trying to install both plotly and cufflinks. However I had a problem.
The installation of both plotly and cufflinks were successful. Although, I can't import cufflinks.
Below is a picture of the problem. It seems to be a dependency error:
I tried manually downloading and installing "talib" but I keep getting failures. (Shown below).
talib\common.c(240): fatal error C1083: Cannot open include file: 'ta_libc.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
Any Ideas? I tried re-installing both modules and Anaconda. Nothing So far.
Other infos:
Cufflinks version: 0.11.0
Plotly version: 2.0.10
Anaconda version: 3-4.4.0 (But I don't think it have anything to do with it)
Python version: 3.6.1
try installing this version of cufflinks, it eliminated the error for me.
pip install cufflinks==0.8.2
From this link: github.com/mrjbq7/ta-lib#troubleshooting
Troubleshooting
Sometimes installation will produce build errors like this:
func.c:256:28: fatal error: ta-lib/ta_libc.h: No such file or directory
compilation terminated.
This typically means that it can't find the underlying TA-Lib library, a dependency which needs to be installed. On Windows, this could be caused by installing the 32-bit binary distribution of the underlying TA-Lib library, but trying to use it with 64-bit Python.
Windows
Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib
This is a 32-bit release. If you want to use 64-bit Python, you will need to build a 64-bit version of the library.
My Fix
So, for windows, we need a 64-bit version of the library? Luckly I found a lot of modules built for 32 and 64 bits python:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
search for "ta-lib" and click on the module you need (In my case cp36 64 bits).
Then, open the command prompt.
Change to where you downloaded the file: cd path/to/file
Type: pip install NameOfFile (in my case pip install TA_Lib‑0.4.10‑cp36‑cp36m‑win_amd64.whl )
Now the 64-bits Ta-Lib module should be installed in your machine. I tested the previous line of codes and it worked!
Thanks for the help :)
I have now removed all dependencies on talib. All studies are pure python based now and you should not face any of this errors.
I have been trying to install Scipy onto my Python 3.5 (32-bit) install on my Windows 7 machine using the pre-built binaries from:
http://www.lfd.uci.edu/~gohlke/pythonlibs
I have, in order, installed the following libraries
numpy‑1.10.1+mkl‑cp35‑none‑win32.whl
scipy‑0.16.1‑cp35‑none‑win32.whl
Then, when trying to use the installed packages I get the following erros
from scipy import sparse
< ... Complete error trace ommitted ... >
packages\scipy\sparse\csr.py", line 13, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: DLL load failed: The specified module could not be found.
However, if i follow the same process for Python 3.4 replacing the installers with:
numpy‑1.10.1+mkl‑cp35‑none‑win32.whl
scipy‑0.16.1‑cp35‑none‑win32.whl
Everything seems to work. Are there additional dependencies or install packages that I am missing for the Python 3.5 install?
Make sure you pay attention to this line from the link you provided:
Many binaries depend on NumPy-1.9+MKL and the Microsoft Visual C++
2008 (x64, x86, and SP1 for CPython 2.6 and 2.7), Visual C++ 2010
(x64, x86, for CPython 3.3 and 3.4), or the Visual C++ 2015 (x64 and
x86 for CPython 3.5) redistributable packages.
Download the corresponding Microsoft Visual C++ Redistributable Package which should be this one based on your description.
I had a similar problem, can't recall the exact issue, and I download the one for my system and it worked fine. Let me know otherwise.
Possibly helpful: trying to pip install scipy-0.18.0rc2-cp35-cp35m-win_amd64.whl (downloaded from http://www.lfd.uci.edu/~gohlke/pythonlibs/) on 64-bit windows 7 with Python 3.5 failed with a "file does not exist/not a valid wheel filename" error.
From various hints obtained from here and elsewhere I found that renaming the file to: scipy-0.16.1-cp35-none-win_amd64.whl allowed it to install.
Pull up the command window (search for it in the start button), then enter
pip install numpy
and
pip install scipy‑0.16.1‑cp35‑none‑win32.whl
then it should let you know in the command window if it was successfully downloaded, if you have python 3.5.
I had a question that turned out to be a duplicate of this one here:
ImportError: DLL load failed: when importing statsmodels
I actually solved this and other issues related to installing packages (such as statsmodels) by using Anaconda installer for Python 3.5.
I downloaded http://pytools.codeplex.com/ (Python Tools for Visual Studio) so that I could write Python in Visual Studio.
The problem is when I try to use the most basic package "numpy" like so:
import numpy
It says "No module named 'numpy'."
How can I use NumPy and SciPy in Visual Studio?
Note: I am using Canopy Express on another machine which works perfectly; however, I don't want to install it on this machine since I already have Visual Studio installed.
I added the Python 3.3 environment to my Python "solution" by right-clicking Python environments and clicking add an environment. But, after right-clicking my environment and clicking install Python package, I typed in "numpy" and got this error when trying to install it:
...
creating build
creating build\src.win32-3.3
creating build\src.win32-3.3\numpy
creating build\src.win32-3.3\numpy\distutils
building library "npymath" sources
No module named 'numpy.distutils.msvccompiler' in numpy.distutils; trying from distutils
error: Unable to find vcvarsall.bat
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in c:\users\dom\appdata\local\temp\pip_build_Dom\numpy
Storing complete log in C:\Users\Dom\pip\pip.log
'numpy' failed to install. Exit code: 1
How can I install NumPy?
In Visual Studio 2013 Community Edition with a Python 2.7 environment, the following worked for me:
Open the Python Environments menu in Solution Explorer, and click on "Install Python Package..."
Then write "numpy":
Two solutions worked for me:
Going directly to my Python folder and installing the packages using pip.
Creating a virtual environment in my project and installing packages from within Visual Studio.
Consider using a more feature-rich Windows distribution of Python, like Anaconda. It comes with a boatload of packages included into the installer. This is quite handy for those who are new to Python, especially when they are using Windows.
Edit:
As of 2020, I would suggest using the python.org distribution of Python. Compiler issues on ms-windows have finally been fixed, so a lot of projects now provide binary packages (wheels) for ms-windows. Among others numpy, pandas, matplotlib, pillow, Cython and PyNaCl.
Note that wheel names ending in:
win_amd64.whl are for 64-bit versions of ms-windows, and
win32.whl are for 32-bit.
I actually ran into the same set of problems when trying to use Visual Studio for Python.
I managed to get things to work at the end - please see Using Visual Studio 2013 for Python (3.4) with NumPy and SciPy on Windows for details. Essentially you can either use the installer (if one is available) or use pip to do the installation.
Make sure C++ Common Tools are installed in Visual Studio:
See under Extra in the Visual Studio (Extra-Python-Interactive Window).
It has the ability to switch the interactive console through a different platform/Python version (32-bit, 64-bit, Debug, and Anaconda (which has the NumPy package)).
From PTVS Installation:
2. Installing packages individually
Here are some recommended packages. Generally you want to install packages using pip or through the interface in Visual Studio (which uses pip), as this will ensure that you get the latest version that will work with your version of Python, as well as any dependencies.
Some packages have complex dependencies and need to be downloaded manually, either from the project's website or from Christoph Gohlke's package collection.
I installed numpy and scipy from these links, and it works perfectly with Visual Studio.
numpy http://sourceforge.net/projects/numpy/files/NumPy/
scipy http://sourceforge.net/projects/scipy/files/scipy/
Matplotlib http://matplotlib.org/downloads.html
Pandas http://pandas.pydata.org/getpandas.html
Well, if anyone still has problem than what worked for me is:
C:/Users/DELL/AppData/Local/Programs/Python/Python39/python.exe -m pip install numpy
where the first part is simply the path of python.
Using pip install zipline on Windows 8 with Python 2.7 gives me the error:
Downloading/unpacking six (from python-dateutil==2.1->delorean->zipline[all])
Running setup.py egg_info for package six
Installing collected packages: blist, pytz, requests, python-dateutil, six
Running setup.py install for blist
building '_blist' extension
error: Unable to find vcvarsall.bat
Complete output from command C:\Python27\python.exe -c "import setuptools;__
file__='c:\\users\\ThatsMe\\appdata\\local\\temp\\pip-build-ThatsMe\\blist\\setup.py';ex
ec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
all --record c:\users\ThatsMe\appdata\local\temp\pip-xvoky2-record\install-record.tx
t --single-version-externally-managed:
running install
running build
running build_py
running build_ext
building '_blist' extension
error: Unable to find vcvarsall.bat
Question: How can the error be resolved? Running pip install zipline[all] gives the same error...
The problem here is the line 292 (Using Python 3.4.3 here) in $python_install_prefix/Lib/distutils/msvc9compiler.py which says:
VERSION = get_build_version()
This only checks for the MSVC version that your python was built with. Just replacing this line with your actual Visual Studio version, eg. 12.0 for MSVC2013
VERSION = 12.0
will fix the issue.
UPDATE: Turns out that there is a good reason why this version is hardcoded. MSVC C runtime is not required to be compatible between major versions. Hence when you use a different VS version you might run into runtime problems. So I advise to use VS 2008 (for Python 2.6 up to 3.2) and VS2010 for (Python 3.3 and later) until this issue is sorted out.
Binary compatibility will arrive with VS 2015 (see here) along with Python 3.5 .
For Python 2.7 users Microsoft released a special Microsoft Visual C++ Compiler for Python 2.7 which can be used without installing the whole VS 2008.
You could use ol' good easy_install zipline instead.
easy_install isn't pip but one good aspect of it is the ability to download and install binary packages too, which would free you for the need having VC++ ready. This of course relies of the assumption that the binaries were prepared for your Python version.
UPDATE:
Yes, Pip can install binaries now!
There's a new binary Python archive format (wheel) that is supposed to replace "eggs". Wheels are already supported by pip. This means you'll be able to install zipline with pip without compiling it as soon as someone builds the wheel for your platform and uploads it to PyPI.
If you are getting this error on Python 2.7 you can now get the Microsoft Visual C++ Compiler for Python 2.7 as a stand alone download.
If you are on 3.3 or later you need to install Visual Studio 2010 express which is available for free here: https://www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express
If you are 3.3 or later and using a 64 bit version of python you need to install the Microsoft SDK 7.1 that ships a 64 bit compiler and follow the directions here Python PIP has issues with path for MS Visual Studio 2010 Express for 64-bit install on Windows 7
First, you should look for the file vcvarsall.bat in your system.
If it does not exist, I recommend you to install Microsoft Visual C++ Compiler for Python 2.7. This will create the vcvarsall.bat in "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0" if you install it for all users.
The problem now is in the function find_vcvarsall(version) in the C:/Python27/Lib/distutils/msvc9compiler.py module, which is looking for the vcvarsall.bat file.
Following the function calls you will see it is looking for an entry in the registry containing the path to the vcvarsall.bat file. It will never find it because this function is looking in other directories different from where the above-mentioned installation placed it, and in my case, the registry didn't exist.
The easiest way to solve this problem is to manually return the path of the vcvarsall.bat file. To do so, modify the function find_vcvarsall(version) in the msvc9compiler.py file with the absolute path to the vcvarsall.bat file like this:
def find_vcvarsall(version):
return r"C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat"
This solution worked for me.
If you already have the vcvarsall.bat file you should check if you have the key productdir in the registry:
(HKEY_USERS, HKEY_CURRENT_USERS, HKEY_LOCAL_MACHINE or HKEY_CLASSES_ROOT)\Software\Wow6432Node\Microsoft\VisualStudio\version\Setup\VC
Where version = msvc9compiler.get_build_version()
If you don't have the key just do:
def find_vcvarsall(version):
return <path>\vcvarsall.bat
To understand the exact behavior check msvc9compiler.py module starting in the find_vcvarsall(version) function.
Simply because you don't have c++ compiler installed there in your machine, check the following
Download Microsoft Visual C++ 2008 from this page. That is a generally useful page anyway, so you should probably bookmark it. For Python 3.3+ use MS Visual C++ 2010.
Install it.
Open Windows explorer (the file browser) and search for the location of ‘vcvarsall.bat’ and cut it to your clipboard.
run regedit from the Windows start key. You will need admin privilges.
Add a registry entry to
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir (64 bit Windows) or
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir (32 bit)
as described here.
Hint: 0.9 in the registery directory is the currently installed version of your visual studio, if you running VS 2013, you have to find the path HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\12.0....
At the Windows start key, type cmd to get a command shell. If you need to, go to your virtual environment and run activate.bat.
pip install or whatever you use to install it.
You need to have Visual Studio's bin dir in your path. Pip install is trying to compile some C code.
I spent hours researching this vcvarsall.bat as well. Most answers on SO focus on Python 2.7 and / or creating workarounds by modifying system paths. None worked for me. This solution worked out of the box for Python 3.5 and (I think) is the "correct" way of doing it.
See this link -- it describes the Windows Compilers to use for different versions of Python: https://wiki.python.org/moin/WindowsCompilers#Microsoft_Visual_C.2B-.2B-_14.0_standalone:_Visual_C.2B-.2B-_Build_Tools_2015_.28x86.2C_x64.2C_ARM.29
For Python 3.5, download this: https://www.microsoft.com/en-us/download/details.aspx?id=49983
For me, I had to run C:\Program Files (x86)\Microsoft Visual C++ Build Tools\Visual C++ x64 Native Build Tools Command Prompt for it to work. From that command prompt, I ran "pip install django_compressor" which was the particular package that was causing me an issue, and it worked perfectly.
Hope this saves someone some time!
Thanks to "msoliman" for his hint, however his answer doesn't give clear solution for those who doesn't have VS2010
For example I have VS2012 and VS2013 and there are no such KEYs in system registry.
Solution:
Edit file: "[Python_install_loc]/Lib/distutils/msvc9compiler.py"
Change on line 224:
productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
"productdir")
to:
productdir = "C:\Program Files (x86)\Microsoft Visual Studio [your_vs_version(11/12...)]\VC"
and that should work
If you are trying to install matplotlib in order to work with graphs on python. Try this link.
https://github.com/jbmohler/matplotlib-winbuild.
This is a set of scripts to build matplotlib from source on the MS Windows platform.
To build & install matplotlib in your Python, do:
git clone https://github.com/matplotlib/matplotlib
git clone https://github.com/jbmohler/matplotlib-winbuild
$ python matplotlib-winbuild\buildall.py
The build script will auto-detect Python version & 32/64 bit automatically.
I appreciate this might not be the answer to resolving on 3.4 but I tried a huge variety of things to fix this on 3.4 and thought this might be useful if someone is time pressed or doesn't have the know-how to correct it (in my case, work demands).
With exactly the same setup, I found that my installation problems only happened with Python 3.4. When I changed to 2.7, all my issues seemed to be resolved.
We have a rather overzealous security setup though so I'm going to try the same on my home version (still 3.4) and see if I have any more joy. My inclination is that my VS version has somehow been restricted and the answers above should help. If I find anything more tonight I'll add further detail.
This is my first reply, not the most technical I'm afraid!