h5py install error failed with exit status 2 - python

I am using Windows 7 and Python 2.7.9. I tried to install h5py with pip, but have the following error:
[c:\users\dell\appdata\local\temp\pip-build-j2msd9\h5py\h5py\api_compat.h(27) : fatal error C1083: cannot open include file:“hdf5.h”: No such file or directory
error: command 'd:\visual studio 2008\VC\BIN\amd64\cl.exe' failed with exit status 2
things I have tried:
Reinstall Visual Studio 2008 compiler
installed some necessary modules such as modHDF5 and numpy

The error you are getting is because you have not installed HDF5, or you have not specified the directory that HDF5 has been installed into.
The simplest thing to do, is to try to install h5py with a modern pip which supports wheels (e.g. run python.exe -m pip install -U pip, and then try reinstalling h5py).
If you want to build from source on Windows, see http://docs.h5py.org/en/latest/build.html#source-installation-on-windows, but I strongly recommend using wheels on Windows (as the person who wrote said CI scripts).

I changed the version of h5py to 2.9.0 and it worked like a charm
Please check what version is installed along with Pre-built package.

Related

Pip install results in this error " cl.exe' failed with exit code 2 "

I've read all of the other questions on this error and frustratingly enough, none give a solution that works.
If I run pip install sentencepiece in the cmd line, it gives me the following output.
src/sentencepiece/sentencepiece_wrap.cxx(2809): fatal error C1083: Cannot open include file: 'sentencepiece_processor.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
I'm running python 3.10.1 and pip 22.0.3 .
*I have the following Microsoft Visual C++ programs on my windows machine,which I've just done a fresh install of as it was complaining of not having a particular C++ program.
MS VC++
I've even added the .exe file to my PATH variables but still I get the same error.
Am I missing a particular Microsoft program on my pc?
I haven't seen this problem in Windows, but for Linux, I would normally reinstall Python after installing the dependencies (such as the MSVC thing). In that case this is especially helpful because I'm often rebuilding (compiling and other related steps) Python/Pip.
Could also just be an error specific to the module and Python version combo you're trying.
From a discussion in the comments:
I have the pyenv-win version manager, so I was able to create venvs and test this for you. With Python 3.10.2, it fails; with Python 3.8.10, it's successful. So, yes, reinstalling does seem to be worthy of your time.
With python3.10
On Windows: First, install vcpkg and install sentencepiece:x64-windows-static
copy the header and lib files from vcpkg/installed/x64-windows-static/include and lib to
C:/Program Files/python310/build/root/include and lib
This should work as the setup.py install expects the library in a ..\build\root\lib directory.
As the C:\Program Files\python310\lib is in the /LIBPATH, the resulting ..\build\root\lib will point to the sentencepiece.lib
If still encounting errors, then set the INCLUDE and LIB environment variables so that the cl.exe , which is called from pip install sentencetransformers finds them.
People having windows+python 3.10 env, here are exact steps to install it via vcpkg.
Other instructions are covered in zweistein's answer.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install sentencepiece:x64-windows-static

How to fix errors occurring on installation of Jupyter Notebook

I am new to Python and try to install Jupyter Notebook from within a Windows command prompt window using:
pip install jupyter
But after a couple of minutes of downloading, an error message is displayed as shown below:
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\asd\appdata\local\programs\python\python38-32\python.exe
' 'c:\users\asd\appdata\local\programs\python\python38-32\lib\site-packages\pip\
_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\asd\Ap
pData\Local\Temp\tmpnj_hhq6y'
cwd: C:\Users\asd\AppData\Local\Temp\pip-install-_pnki5r8\pywinpty
Complete output (6 lines):
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\asd\appdata\local\progr
ams\python\python38-32\python.exe' 'c:\users\asd\appdata\local\programs\python\p
ython38-32\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata
_for_build_wheel 'C:\Users\asd\AppData\Local\Temp\tmpnj_hhq6y' Check the logs for
full command output.
WARNING: You are using pip version 20.2.1; however, version 21.1 is available.
You should consider upgrading via the 'c:\users\asd\appdata\local\programs\pytho
n\python38-32\python.exe -m pip install --upgrade pip' command.
I have attached here just the last part of the error output.
How to fix this error for a successful installation of Jupyter Notebook?
EDIT1: I installed the Rust package from the link in the error message. After that I tried installing Jupyter Notebook once again, and this time after proceeding a few steps further than before, it output another error:
Building wheels for collected packages: pywinpty
Building wheel for pywinpty (PEP 517) ... - WARNING: Subprocess output does
not appear to be encoded as cp1252
WARNING: Subprocess output does not appear to be encoded as cp1252
error
ERROR: Command errored out with exit status 1:
command: 'c:\users\asd\appdata\local\programs\python\python38-32\python.exe'
'c:\users\asd\appdata\local\programs\python\python38-32\lib\site-packages\pip\_v
endor\pep517\_in_process.py' build_wheel 'C:\Users\asd\AppData\Local\Temp\tmpaj5
u66_y'
cwd: C:\Users\asd\AppData\Local\Temp\pip-install-mep4ye8d\pywinpty
Complete output (60 lines):
Running `maturin pep517 build-wheel -i c:\users\asd\appdata\local\programs\pyt
hon\python38-32\python.exe`
Compiling proc-macro2 v1.0.26
Compiling unicode-xid v0.2.2
Compiling syn v1.0.71
Compiling winapi v0.3.9
Compiling jobserver v0.1.22
error: could not compile `proc-macro2`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
dY'¥ maturin failed
Caused by: Failed to build a native library through cargo
Caused by: Cargo build finished with "exit code: 101": `cargo rustc --messag
e-format json --manifest-path Cargo.toml --release --lib --`
dY\x8d1 Building a mixed python/rust project
dY"- Found pyo3 bindings
dY\x90\x8d Found CPython 3.8 at c:\users\asd\appdata\local\programs\python\pyt
hon38-32\python.exe
error: linker `link.exe` not found
|
= note: The system cannot find the file specified. (os error 2)
note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed wi
th the Visual C++ option
error: aborting due to previous error
error: linker `link.exe` not found
|
= note: The system cannot find the file specified. (os error 2)
note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed wi
th the Visual C++ option
error: aborting due to previous error
error: linker `link.exe` not found
|
= note: The system cannot find the file specified. (os error 2)
note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed wi
th the Visual C++ option
error: aborting due to previous error
Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'c:\\users\\asd\\app
data\\local\\programs\\python\\python38-32\\python.exe'] returned non-zero exit
status 1
----------------------------------------
ERROR: Failed building wheel for pywinpty
Failed to build pywinpty
ERROR: Could not build wheels for pywinpty which use PEP 517 and cannot be insta
lled directly
WARNING: You are using pip version 20.2.1; however, version 21.1 is available.
You should consider upgrading via the 'c:\users\asd\appdata\local\programs\pytho
n\python38-32\python.exe -m pip install --upgrade pip' command.
Upgrade your pip first:
pip install --upgrade pip
Then:
pip install jupyter
I'reached this post after failing to install notebook on a 32-bit python 3.8.3 execution. And as far as I found, pywinpty, which is a dependence, does not support 32-bit executions (see sources below).
I solved the problem by installing python on its 64-bit version.
Sources:
How do I determine if my python shell is executing in 32bit or 64bit?
pip install fails on Python 3.8 32-bit, prevents Jupyter install #129 which simply says that wheels cannot be installed with 32 bit Python and that you should use 64 bit Python instead.
We can't generate 32 bit wheels, sorry. Please use a 64bit build of Python.. Was not my case but might be useful this similar issue when using python 3.8 64-bit
Error installing Jupyter & pywinpty (Python)
https://github.com/spyder-ide/pywinpty/issues/123
Do
pip install wheel
and try again. It worked for me.
What to do:
Check if your python is 64-bit version. If no, go to python site (for example, here is the link to download 3.7.9. Just click at the version that has label "for AMD64/EM64T/x64", do it with any version you wish, just I don't like to use the newest version). Remove yours (with the uninstall file) and download this. Don't forget to put the checkmark near "Add PATH" below;
Download Rust (the description is inside) - you need some files. Check the PATHs - if you want to change them, do it (the names of the variables and where they are - both are written, you can search in the Internet how to change PATH var's (for example));
Go to Windows Shell with admin mode (Win+X and you get the field) - here is the most comfortable place to work;
Go to your python.exe (for example, my way is C:\Users\user\AppData\Local\Programs\Python\Python37) - just for sure;
python.exe python -m pip install --upgrade pip;
python.exe pip install jupyter;
If an error was returned that contains the missing of wheel, try to download it: python.exe pip install wheel.
Donwload any library you miss during installation and continue since the step you stopped at.
Try using Anaconda. link to install conda https://www.anaconda.com/products/individual
then cmd : conda install numpy
cmd: conda install jupyter
cmd : jupyter notebook
The error message looks quite clear, you needs to install Cargo via https://rustup.rs/
I have faced the same issue when I'm using vscode. The simplest solution is to use conda instead of pip
conda install jupyterlab

Could not import cufflinks

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.

installing pyside using PIP - nmake not found

I want to install PySide using PIP package manager. But it get this error message saying it didn't find nmake. This is no surprise because I do not have MSVC installed nor do I intend to.
Installing collected packages: pyside
Running setup.py install for pyside
Removing c:\users\cnyffele\appdata\local\temp\pip_build_cnyffele\pyside\pyside_package
Python architecture is 32bit
nmake not found. Trying to initialize the MSVC env...
Searching MSVC compiler version 9.0
error: Failed to find the MSVC compiler version 9.0 on your system.
However the setup.py program could simply run make:
C:\Users\cnyffele>where make
C:\MinGW32-xy\bin\make.exe
C:\Users\cnyffele>where mingw32-make
C:\MinGW32-xy\bin\mingw32-make.exe
But for some reason, it insists that if the platform is "win32" it should use msvc without trying anything else. It does, however, accept command-line options: I could specify "make-spec" to be "mingw" (see below).
From https://github.com/PySide/pyside-setup/blob/master/setup.py
OPTION_MAKESPEC = option_value("make-spec")
...
if sys.platform == "win32":
if OPTION_MAKESPEC is None:
OPTION_MAKESPEC = "msvc"
if not OPTION_MAKESPEC in ["msvc", "mingw"]:
print("Invalid option --make-spec. Available values are %s" % (["msvc", "mingw"]))
sys.exit(1)
How can I make setyp.py use the correct make when installing with PIP? Is there a way to have PIP provide command-line options to setup.py when it runs it? If this is not possible, how can I run setup.py manually after PIP downloaded it?
PIP allows passing options to setup via the options '--global-option' and '--install-option' as described in the pip reference guide.
The solution is:
pip install --global-option="--make-spec=mingw" PySide
Some additional information:
That prior to installing PySide using pip, you have to install cmake and Qt 4.8.
Build errors prevented me from downloading and installing PySide directly via pip. I needed to download the wheel binary packages from pypi.python.org.
Using a pre-downloaded .whl package, assuming the package is located in the current working directory:
pip install --global-option="--make-spec=mingw" PySide-1.2.4-cp27-none-win32.whl

pyzmq installation error with dependency on gcc

I tried installing pyzmq by http://ipython.org/ipython-doc/dev/install/install.html as I want to install ipython. But it has dependency on pyzmq which has dependency on gcc. I already have gcc installed but still I am getting the following error while install pyzmq.
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
The script also has following in it:
If you expected pyzmq to link against an installed libzmq, please check to make sure:
* You have a C compiler installed
* A development version of Python is installed (including headers)
* A development version of ZMQ >= 2.1.4 is installed (including headers)
* If ZMQ is not in a default location, supply the argument --zmq=<path>
* If you did recently install ZMQ to a default location,
try rebuilding the ld cache with `sudo ldconfig`
or specify zmq's location with `--zmq=/usr/local`
You can skip all this detection/waiting nonsense if you know
you want pyzmq to bundle libzmq as an extension by passing:
`--zmq=bundled`
I will now try to build libzmq as a Python extension
I already have all the above but still issues. I am guessing I have path issues i.e. may be pyzmq is looking at other location but how do I solve this problem
This is a huge issue in Windows to install ipython. I would recommend Windows users to never go the pip or easy_install way to install it. I faced a lot of issues like above. I read that it still has dependencies issues on github i.e. via pip.
I got it installed finally by this:
Download and install Anaconda
Update IPython to the current version by:
Go to Anaconda directory or look for anaconda cmd & do the following:
conda update conda
conda update ipython

Categories