Installing Sklearn from Source on Windows 7 - scikit-learn

I am on Windows 7 (64 bit) and have Python 3.4 installed along with the other stated required dependencies for the sklearn python package [NumPy (>= 1.6.1), SciPy (>= 0.9)]. I installed Numpy and SciPy from the .whl files I found online that matched python 3.4. I am trying to install the sklearn package by calling pip install sklearn (FYI, I am trying to do this install without using Python (x.y) because I want python 3.x). the pip install sklearn command will run for a while, but then I get the following error:
copying sklearn\tests\__init__.py -> build\lib.win-amd64-3.4\sklearn\tests
running build_clib
customize MSVCCompiler
Missing compiler_cxx fix for MSVCCompiler
customize MSVCCompiler using build_clib
building 'libsvm-skl' library
compiling C sources
error: Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows SDK 7.1": www.microsoft.com/download/details.aspx?id=8279
----------------------------------------
Command "c:\python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\jjaaae\\AppData\\Local\\Temp\\pip-build-43xaawp2\\scikit-learn\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\jjaaae\AppData\Local\Temp\pip-7i3ghuri-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\jjaaae\AppData\Local\Temp\pip-build-43xaawp2\scikit-learn\
I have tried to install Microsoft Windows SDK 7.1 as it describes in the error message. I have also restarted the command prompt and my computer, but I still get this error message. What am I missing?

I found the problem. The download file for Microsoft Windows SDK 7.1 allows you to "install" it even if you don't have .Net 4.x installed yet. I must have gotten click happy during the install and missed that warning. So the install for SDK 7.1 was really fast and didn't install what I needed. When I backed up, installed Microsoft .NET Framework 4 from this URL first, then installed SDK 7.1 per instructions it worked.

Related

Getting error while installing any module using "pip install ..." in cmd [duplicate]

I installed python 3.7 on my Windows 10 laptop since it has been officially released as of today (06/28/2018). Then i tried to install numpy package using pip
pip install numpy
The install proceeds but finally fails with the below error :
source = func(extension, build_dir)
File "numpy\core\setup.py", line 675, in get_mathlib_info
raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
----------------------------------------
Command ""c:\program files\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\pcheg\\AppData\\Local\\Temp\\pip-install-7wjkw5wn\\numpy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\pcheg\AppData\Local\Temp\pip-record-uhj8233f\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\pcheg\AppData\Local\Temp\pip-install-7wjkw5wn\numpy\
Any ideas as to how to overcome this install Error? Thanks.
Installing NumPy on Windows is a common problem if you don't have the right build setup. Instead, I always go to Christoph Gohlke's website to download the wheels you can install for your computer. Christoph generously builds the libraries himself with the right build environment and he posts it on his website.
Newer Instructions - For older instructions, please scroll down
First, install pipwin from PyPI which will install a utility that acts like pip but it will download the actual package you're interested in from his website, then use pipwin install to install the package you want.
First do:
pip install pipwin
When that's installed, you can then do:
pipwin install numpy
This will install the latest version of NumPy on your system. This way you don't have to specifically search for the version of NumPy that is for your specific version of Python.
Older instructions
Go to the NumPy section: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy then download the version for 3.7 that is compatible with your version of Python (2 or 3 and 32-bit or 64-bit). For example, the filename numpy‑1.14.5+mkl‑cp37‑cp37m‑win_amd64.whl is for NumPy 1.14.5, Python 3.7 - 64 bit. You can pick out which version of NumPy and which version of the Python interpreter and bit version you need in the filename.
Doing this never requires you to build NumPy yourself or install the required compiler as opposed to installing NumPy through PyPI. You can just download the wheel and install it yourself. Assuming you've already downloaded it, just do:
pip install numpy‑1.14.5+mkl‑cp37‑cp37m‑win_amd64.whl
... assuming the wheel is in the directory you're currently in.
Starting 24 November 2021, latest numpy require at least Python 3.8
Note: This might not be the original question asked, but it might help anyone come here.
To use python 3.7, latest numpy you can use is v1.21.4. So, to install it, use:
pip install numpy==1.21.4
If you write requirements that you hope compatible with python 3.7, you can use numpy<=1.21.4
EDIT: in 20 December 2021, numpy release version 1.21.5 that support Python 3.7
From comment section, by #sam, numpy 1.21.5 support Python 3.7. It was released after 1.22.0rc1 (the latest numpy version as the writing of the original post) that only support Python 3.8++.
Lesson learned from this experience, it would be better to use <,
pip install numpy<1.22.0
or
install_requires = [
"numpy<1.22.0", # lates version to support python 3.7
],
For windows when you install a package you type in Python 3:
py -m pip install [packagename]
OR
py -m pip install numpy
You're probably missing a C compiler. If numpy doesn't provide a prebuilt wheel yet, you'll need to install a compiler. This website shows the one you need to install. For 3.7, I assume it's still 14.0, so you should install Microsoft Build Tools for Visual Studio 2017.
Let me know if that works.

Can't install Ta-Lib with pip in Ubuntu 18.04

I need to install the TA-Lib library on python. Where I run the following:
pip install TA-Lib --user
I get this error code:
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-52h2r7l4/TA-Lib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-meoq431k/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-52h2r7l4/TA-Lib/
I have also tried:
pip3 install TA-Lib
when I run:
python --version
I get:
Python 2.7.15rc1
Then I run:
python3 --version
I get:
Python 3.6.7
I can't understand. I have Ubuntu 18.04. Before I have Anaconda, then delete it (hope I delete it correctly) And then install Python 2.7 because I wanted to use Zipline to backtest some strategies, but I cannot use TA-Lib.
Hope someone know the problem, thank you!
I've downloaded TA-Lib-0.4.17.tar.gz that pip3 gets automatically. Opened it - there is no TA-Lib, only wrapper for it. According to its README.md
Dependencies
To use TA-Lib for python, you need to have the TA-Lib already installed. You should probably follow their installation directions for your
platform, but some suggestions are included below for reference.
Mac OS X
$ brew install ta-lib
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.
Some unofficial (and unsupported) instructions for building on 64-bit Windows 10, here for reference:
Download and Unzip ta-lib-0.4.0-msvc.zip
Move the Unzipped Folder ta-lib to C:\
Download and Install Visual Studio Community 2015
Remember to Select [Visual C++] Feature
Build TA-Lib Library
From Windows Start Menu, Start [VS2015 x64 Native Tools Command Prompt]
Move to C:\ta-lib\c\make\cdr\win32\msvc
Build the Library nmake
Linux
Download ta-lib-0.4.0-src.tar.gz and:
$ untar and cd $ ./configure --prefix=/usr $ make $ sudo make install
If you build TA-Lib using make -jX it will fail but that’s OK! Simply rerun make -jX followed by [sudo] make install.
ta-lib depends on their C implementation you have to install it before installing the python version.

Pandas installation not recognising a C++ install

I'm installing Pandas along with a few others dependencies for a graph theory project on a new machine.
I'm installing all the dependencies with pip, with Pandas being installed with pip install pandas.
The installation fails with:
running build_ext
building 'pandas._libs.algos' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
----------------------------------------
Command ""c:\program files (x86)\python37-32\python.exe" -u -c "import setuptool
s, tokenize;__file__='C:\\Users\\USER\\AppData\\Local\\Temp\\pip-install-q9t
aeyul\\pandas\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read
().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" instal
l --record C:\Users\USER\AppData\Local\Temp\pip-record-9bazi_ha\install-reco
rd.txt --single-version-externally-managed --compile" failed with error code 1 i
n C:\Users\USER\AppData\Local\Temp\pip-install-q9taeyul\pandas\
I have then proceeded to install the Microsoft Visual C++ 2015 Redist 14.0 from this link.
The C++ 2015 Redist version numbers are 14.0.23026 for 64-bit and 14.0.24215 for 32-bit. I also have various other C++ Redists from other years, down to 2005.
I restarted the computer after installing the Redist, just to ensure there are no problems on that front. However, I'm still getting the same error.
I'm on Windows 8.1.
Visual C++ Redistributable installs run-time libraries and can be used to run applications written with VC. But you need Visual C++ compiler! So install Build Tools.

Can't install cx_Freeze or scipy for Python 3.7 64-bit

I'm trying to install cx_Freeze and scipy but I get a
compile failed with error code 1
error every time. Here's what I see when I try to do it with cx_Freeze:
error: file 'C:\Users\myAccount\AppData\Local\Temp\pip-install-nabp1tpo\cx-fre
eze\cxfreeze-postinstall' does not exist
----------------------------------------
Command "c:\users\myAccount\appdata\local\programs\python\python37\python.exe -u -
c "import setuptools, tokenize;__file__='C:\\Users\\myAccount\\AppData\\Local\\Tem
p\\pip-install-nabp1tpo\\cx-freeze\\setup.py';f=getattr(tokenize, 'open', open)(
__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __fil
e__, 'exec'))" install --record C:\Users\myAccount\AppData\Local\Temp\pip-record-3
6fbtmht\install-record.txt --single-version-externally-managed --compile" failed
with error code 1 in C:\Users\myAccount\AppData\Local\Temp\pip-install-nabp1tpo\c
x-freeze\
How can I fix this?
You could manage to install it from wheel.
First you need to install wheel:
pip install wheel
Then go to the following link to download the cx_Freeze wheel file according to you python version and windows version:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#cx_freeze
For 64bit and Python 3.7: cx_Freeze‑5.1.1‑cp37‑cp37m‑win_amd64.whl
On your command prompt change directory to the downloaded folder and use the command:
pip install cx_Freeze‑5.1.1‑cp37‑cp37m‑win_amd64.whl
For further description on installing from wheel, check the following link: https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels
The same method will solve your problem to install scipy.
It seems that this problem occurs because the version on PyPI isn't up to date.
It works for me when I manually download it from the master branch on GitHub.
pip install --upgrade git+https://github.com/anthony-tuininga/cx_Freeze.git#master
Got this answer from issue #407 published on the GitHub page.
I tried Nischal's solution (which worked) but then ran into more errors down the line.
I then rolled back python to 3.6-32bit and everything worked flawlessly, just a heads up to whoever else gets this, unless you can get cx_freeze 6.0 installed it may be easier to rollback to python3.6 (or make a virtualenv of it).
I downloaded 32 bit installer when 64 bit didn't work.
pip install cx_Freeze-5.1.1-cp37-cp37m-win32.whl
This works fine for me. So I guess no need to downgrade to Python 3.6
I am using Python 3.7 (64-bit)
Download cx_Freeze here (depending on your Python version):
And paste this .whl file in working directory.
Open command prompt, paste following command and press enter:
pip install cx_Freeze-5.1.1-cp37-cp37m-win_amd64.whl
Please note that this command is for Python 3.7(64-bit)
Output should look like:
Processing c:\users\Python37\cx_freeze-5.1.1-cp37-cp37m-win_amd64.whl*
Installing collected packages: cx-Freeze*
Successfully installed cx-Freeze-5.1.1*

Cannot find vcvarsall.bat

NOTE: I have seen multiple answers to no avail, so please look at the solution and my failed solutions list before showing as duplicate.
Hey,
So I got a new computer (Old Windows w/ Python 3.4), so I installed Python 3.5 on my new one. I started to install modules until I came across an error like this:
C:\Users\Samuel>pip install noise
Collecting noise
Using cached noise-1.2.2.tar.gz
Installing collected packages: noise
Running setup.py install for noise
Complete output from command "c:\program files\python 3.5\python.exe" -c "import setuptools, tokenize;__file__='C:\\Users\\Samuel\\AppData\\Local\\Temp\\pip-build-e9dlwpm2\\noise\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Samuel\AppData\Local\Temp\pip-7tgvnyfe-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\noise
copying perlin.py -> build\lib.win-amd64-3.5\noise
copying setup.py -> build\lib.win-amd64-3.5\noise
copying shader.py -> build\lib.win-amd64-3.5\noise
copying shader_noise.py -> build\lib.win-amd64-3.5\noise
copying test.py -> build\lib.win-amd64-3.5\noise
copying __init__.py -> build\lib.win-amd64-3.5\noise
running build_ext
building 'noise._simplex' extension
error: Unable to find vcvarsall.bat
----------------------------------------
Command ""c:\program files\python 3.5\python.exe" -c "import setuptools, tokenize;__file__='C:\\Users\\Samuel\\AppData\\Local\\Temp\\pip-build-e9dlwpm2\\noise\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Samuel\AppData\Local\Temp\pip-7tgvnyfe-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Samuel\AppData\Local\Temp\pip-build-e9dlwpm2\noise
I tried to use easy_install as a substitute, but that came with 1) an access denied error (Overcome w/ admin privelages) and 2) Not being able to find vcvarsall.bat
Because of this, I installed Visual Studio 2015 and Visual C++ 2008.
No difference.
I added the path to vcvarsall.bat to the PATH.
No difference.
I added the path to vcvarsall.bat to VS100COMNTOOLS, VS140COMNTOOLS and VS90COMNTOOLS.
No difference.
Running pip and easy_install again w/ admin permission, wearing my lucky socks.
No difference.
Installed and ran Miniconda as suggested by one of the Stack Overflow answers.
Didn't find a single package I needed. Turns out it's not looking for PyPI anyway.
I have no idea how to solve this. Do I need to revert to Python 3.4?
SPECS
Windows 10 x86 64-bit
Python 3.5
VS 2015, VC++ 2008 installed
I think you have the wrong C++: VC++ 2008 is for Python before 3.3.
The VC++ 2015 that you need comes when you install Visual Studio 2015 but you need to explicitly specify the C++ (check the box) for the C++ (2015) in the custom installation options. Try changing that via a re-installation.
Just tried it:
Windows 10 x86 64-bit
Python 3.5
VS 2015 But with the Visual C++ install option checked
Then pip install noise worked fine.

Resources