Python : Failing to install scikit-learn (error code 1) on widows - python

I followed the instructions on the official sklearn website, and even if I fulfil the requirements I still cannot install sklearn. Here is the error message I get :
ERROR: Command errored out with exit status 1:
command: 'd:\others\python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\anath\\AppData\\Local\\Temp\\pip-install-dnha64ok\\scikit-learn\\setup.py'"'"'; __file__='"'"'C:\\Users\\anath\\AppData\\Local\\Temp\\pip-install-dnha64ok\\scikit-learn\\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\anath\AppData\Local\Temp\pip-record-s7idmuvg\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\
Complete output (44 lines):
Partial import of sklearn during the build process.
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
Traceback (most recent call last):
File "d:\others\python\lib\site-packages\setuptools\msvc.py", line 489, in _find_latest_available_vc_ver
return self.find_available_vc_vers()[-1]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\setup.py", line 290, in <module>
setup_package()
File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\setup.py", line 286, in setup_package
setup(**metadata)
File "d:\others\python\lib\site-packages\numpy\distutils\core.py", line 137, in setup
config = configuration()
File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\setup.py", line 174, in configuration
config.add_subpackage('sklearn')
File "d:\others\python\lib\site-packages\numpy\distutils\misc_util.py", line 1033, in add_subpackage
config_list = self.get_subpackage(subpackage_name, subpackage_path,
File "d:\others\python\lib\site-packages\numpy\distutils\misc_util.py", line 999, in get_subpackage
config = self._get_configuration_from_setup_py(
File "d:\others\python\lib\site-packages\numpy\distutils\misc_util.py", line 941, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "sklearn\setup.py", line 76, in configuration
maybe_cythonize_extensions(top_path, config)
File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\sklearn\_build_utils\__init__.py", line 42, in maybe_cythonize_extensions
with_openmp = check_openmp_support()
File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\sklearn\_build_utils\openmp_helpers.py", line 83, in check_openmp_support
ccompiler.compile(['test_openmp.c'], output_dir='objects',
File "d:\others\python\lib\distutils\_msvccompiler.py", line 360, in compile
self.initialize()
File "d:\others\python\lib\distutils\_msvccompiler.py", line 253, in initialize
vc_env = _get_vc_env(plat_spec)
File "d:\others\python\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
File "d:\others\python\lib\site-packages\setuptools\msvc.py", line 843, in __init__
self.si = SystemInfo(self.ri, vc_ver)
File "d:\others\python\lib\site-packages\setuptools\msvc.py", line 485, in __init__
self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
available_vc_ver
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\anath\\AppData\\Local\\Temp\\pip-installpip-install-dnha64ok\\scikit-learn\\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\anath\AppData\Local\Temp\pip-record-s7idmuvg\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
It seems like there is a problem with numpy but I already updated to the latest version.
I'm on Windows 10, using Python 3.7, and numpy/scipy are up to date.
Thanks in advance !

Upgrade your python to 3.8 ,because 3.9.0 also have this installation issue.

I think your problem is with setuptools. Upgrade it using the following command:
pip3 install --upgrade setuptools
And then upgrade your scipy/numpy to the latest version :
pip3 install --upgrade numpy
Your C++ build tools are missing too. Get it from here: https://visualstudio.microsoft.com/visual-cpp-build-tools/

You can go to this site for Binaries for windows:
https://www.lfd.uci.edu/~gohlke/pythonlibs/
here you can find required packages if you don't want to install C++ build tools

Related

RROR: Command errored out with exit status 1 Python

I am installing packages from requirments.txt file using this command
pip install -r C:\Users\MSI\Desktop\pddSpider-master\requirements.txt
it returns after installing some packages:
ERROR: Command errored out with exit status 1:
command: 'c:\users\msi\appdata\local\programs\python\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\MSI\\AppData\\Local\\Temp\\pip-install-i3ladjxy\\cffi_d7086d7149244c569b1d283214caf323\\setup.py'"'"'; __file__='"'"'C:\\Users\\MSI\\AppData\\Local\\Temp\\pip-install-i3ladjxy\\cffi_d7086d7149244c569b1d283214caf323\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\MSI\AppData\Local\Temp\pip-pip-egg-info-sdkc1qs8'
cwd: C:\Users\MSI\AppData\Local\Temp\pip-install-i3ladjxy\cffi_d7086d7149244c569b1d283214caf323\
Complete output (19 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\MSI\AppData\Local\Temp\pip-install-i3ladjxy\cffi_d7086d7149244c569b1d283214caf323\setup.py", line 120, in <module>
if sys.platform == 'win32' and uses_msvc():
File "C:\Users\MSI\AppData\Local\Temp\pip-install-i3ladjxy\cffi_d7086d7149244c569b1d283214caf323\setup.py", line 98, in uses_msvc
return config.try_compile('#ifndef _MSC_VER\n#error "not MSVC"\n#endif')
File "c:\users\msi\appdata\local\programs\python\python38-32\lib\distutils\command\config.py", line 225, in try_compile
self._compile(body, headers, include_dirs, lang)
File "c:\users\msi\appdata\local\programs\python\python38-32\lib\distutils\command\config.py", line 132, in _compile
self.compiler.compile([src], include_dirs=include_dirs)
File "c:\users\msi\appdata\local\programs\python\python38-32\lib\distutils\_msvccompiler.py", line 327, in compile
self.initialize()
File "c:\users\msi\appdata\local\programs\python\python38-32\lib\distutils\_msvccompiler.py", line 224, in initialize
vc_env = _get_vc_env(plat_spec)
File "c:\users\msi\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 314, in msvc14_get_vc_env
return _msvc14_get_vc_env(plat_spec)
File "c:\users\msi\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 268, in _msvc14_get_vc_env
raise distutils.errors.DistutilsPlatformError(
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------
Please Check your Microsoft Visual C++ version and upgrade it to version 14.0 or above.

Python PIP issue when installing Ray - The wheel package is not available

I'm trying to install Ray - this can be done with a simple pip install ray
During the installation, packages get downloaded and installed correctly until it reaches gpustat
Python version: 3.8.7
OS: Linux (cflinuxfs3 to be more specific)
Here's the stacktrace
Downloading https://masked-package-path/packages/packages/b4/69/gpustat-0.6.0.tar.gz (78 kB)
ERROR: Command errored out with exit status 1:
command: /tmp/contents295671398/deps/0/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-tdlwfmx8/gpustat/setup.py'"'"'; __file__='"'"'/tmp/pip-install-tdlwfmx8/gpustat/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-4yij8vu9
cwd: /tmp/pip-install-tdlwfmx8/gpustat/
Complete output (22 lines):
WARNING: The wheel package is not available.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-tdlwfmx8/gpustat/setup.py", line 91, in <module>
setup(
File "/tmp/contents295671398/deps/0/python/lib/python3.8/site-packages/setuptools/__init__.py", line 164, in setup
_install_setup_requires(attrs)
File "/tmp/contents295671398/deps/0/python/lib/python3.8/site-packages/setuptools/__init__.py", line 159, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/tmp/contents295671398/deps/0/python/lib/python3.8/site-packages/setuptools/dist.py", line 699, in fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "/tmp/contents295671398/deps/0/python/lib/python3.8/site-packages/pkg_resources/__init__.py", line 779, in resolve
dist = best[req.key] = env.best_match(
File "/tmp/contents295671398/deps/0/python/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1064, in best_match
return self.obtain(req, installer)
File "/tmp/contents295671398/deps/0/python/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1076, in obtain
return installer(requirement)
File "/tmp/contents295671398/deps/0/python/lib/python3.8/site-packages/setuptools/dist.py", line 758, in fetch_build_egg
return fetch_build_egg(self, req)
File "/tmp/contents295671398/deps/0/python/lib/python3.8/site-packages/setuptools/installer.py", line 83, in fetch_build_egg
raise DistutilsError('the `allow-hosts` option is not supported '
distutils.errors.DistutilsError: the `allow-hosts` option is not supported when using pip to install requirements.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
**ERROR** Could not install pip packages: could not run pip: exit status 1
Also, I tried installing wheel (because the WARNING is saying it's missing) but no luck.
Any known issues regarding gpustat-0.6.0?
I had a similar error, but it was caused by gpustat's requirement for pytest-runner.
Running pip install pytest-runner fixed it for me. Just sharing in case anyone else has this problem.
Note: this was being done through a corporate proxy.

Python Urllib ContextualVersionConflict

Till Oct 20, it was fine. Oct 21, it failed with the below messages. Can any one help here
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-i8sl36tr/elasticsearch-curator/setup.py'"'"'; __file__='"'"'/tmp/pip-install-i8sl36tr/elasticsearch-curator/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-et0c4kgw
cwd: /tmp/pip-install-i8sl36tr/elasticsearch-curator/
Complete output (20 lines):
Traceback (most recent call last):
File "/tmp/pip-install-i8sl36tr/elasticsearch-curator/setup.py", line 39, in <module>
from cx_Freeze import setup, Executable
ModuleNotFoundError: No module named 'cx_Freeze'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-i8sl36tr/elasticsearch-curator/setup.py", line 177, in <module>
tests_require = ["mock", "nose", "coverage", "nosexcover"]
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 152, in setup
_install_setup_requires(attrs)
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 147, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 676, in fetch_build_eggs
replace_conflicting=True,
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 775, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (urllib3 1.24.3 (/tmp/pip-install-i8sl36tr/elasticsearch-curator/.eggs/urllib3-1.24.3-py3.7.egg), Requirement.parse('urllib3<1.26,>=1.25.4'), {'botocore'})
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.```
On 19.10.2020 AWS released new botocore version 1.19.0.
So far versions 1.19.0, 1.19.1, 1.19.2 are not compatible with elasticsearch-curator - version 5.8.1.
I had same problem and temporary fixed issue by installing older version of elasticsearch-curator - version 5.6.0.
I believe AWS will soon release botocore version that is compatible with elasticsearch-curator - version 5.8.1.
It looks like your Python environment is inconsistent with the versions requires by your packages. Have you tried installing your environment with the --use-feature=2020-resolver flag?
python -m pip install --use-feature=2020-resolver elasticsearch elasticsearch-curator ...

Unable to install the new tflite-support using pip

Following this link, I've been trying to install the tflite-support module using pip. I get the following error:
ERROR: Command errored out with exit status 1:
command: /usr/local/opt/python/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/gg/1zr67t6d11lczcdmc7tc3y000000gn/T/pip-install-tfso4suc/tflite-support/setup.py'"'"'; __file__='"'"'/private/var/folders/gg/1zr67t6d11lczcdmc7tc3y000000gn/T/pip-install-tfso4suc/tflite-support/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/gg/1zr67t6d11lczcdmc7tc3y000000gn/T/pip-install-tfso4suc/tflite-support/pip-egg-info
cwd: /private/var/folders/gg/1zr67t6d11lczcdmc7tc3y000000gn/T/pip-install-tfso4suc/tflite-support/
Complete output (27 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/gg/1zr67t6d11lczcdmc7tc3y000000gn/T/pip-install-tfso4suc/tflite-support/setup.py", line 178, in <module>
zip_safe=False,
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/setuptools/__init__.py", line 143, in setup
_install_setup_requires(attrs)
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/setuptools/__init__.py", line 138, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/setuptools/dist.py", line 698, in fetch_build_eggs
replace_conflicting=True,
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/pkg_resources/__init__.py", line 783, in resolve
replace_conflicting=replace_conflicting
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/pkg_resources/__init__.py", line 1066, in best_match
return self.obtain(req, installer)
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/pkg_resources/__init__.py", line 1078, in obtain
return installer(requirement)
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/setuptools/dist.py", line 754, in fetch_build_egg
return fetch_build_egg(self, req)
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/setuptools/installer.py", line 133, in fetch_build_egg
wheel.install_as_egg(dist_location)
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/setuptools/wheel.py", line 103, in install_as_egg
self._install_as_egg(destination_eggdir, zf)
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/setuptools/wheel.py", line 111, in _install_as_egg
self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)
File "/Users/anupamchugh/Library/Python/3.7/lib/python/site-packages/setuptools/wheel.py", line 132, in _convert_metadata
os.mkdir(destination_eggdir)
FileExistsError: [Errno 17] File exists: '/private/var/folders/gg/1zr67t6d11lczcdmc7tc3y000000gn/T/pip-install-tfso4suc/tflite-support/.eggs/pybind11-2.4.3-py3.7.egg'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Any leads? I know similar questions have been asked before, but no luck with those answers
Turning the comment into an answer:
This looks like a regression in setuptools. Downgrade to 41:
$ pip install --upgrade 'setuptools<42'
Now (ideally) preinstall pybind11 to avoid missing headers when building the tflite-support wheel:
$ pip install 'pybind11>=2.4'
Now installing tflite-support should succeed without any intermediate errors:
$ pip install tflite-support

pip install pdfminer error (python 2 on Windows)

When I run pip install pdfminer using Python 2.7 on Windows Server 2012, I got the following error :
Running setup.py install for pdfminer ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python27\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\admini~1\\appdata\\local\\temp\\2\\pip-install-xgbxsi\\pdfminer\\setup.py'"'"'; __file__='"'"'c:\\users\\admin
i~1\\appdata\\local\\temp\\2\\pip-install-xgbxsi\\pdfminer\\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\admini~1\appdata\local\temp\2\pip-record-mdl997\install-record.txt' --single-version-externally-managed --compile
cwd: c:\users\admini~1\appdata\local\temp\2\pip-install-xgbxsi\pdfminer\
Complete output (24 lines):
running install
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\admini~1\appdata\local\temp\2\pip-install-xgbxsi\pdfminer\setup.py", line 71, in <module>
'Topic :: Text Processing',
File "c:\python27\lib\site-packages\setuptools\__init__.py", line 143, in setup
return distutils.core.setup(**attrs)
File "c:\python27\lib\distutils\core.py", line 151, in setup
dist.run_commands()
File "c:\python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "c:\python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "c:\users\admini~1\appdata\local\temp\2\pip-install-xgbxsi\pdfminer\setup.py", line 11, in run
from pdfminer.cmapdb import convert_cmap
File "pdfminer\cmapdb.py", line 22, in <module>
from .psparser import PSStackParser
File "pdfminer\psparser.py", line 4, in <module>
from .utils import choplist
File "pdfminer\utils.py", line 219, in <module>
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
File "pdfminer\utils.py", line 187, in <genexpr>
PDFDocEncoding = ''.join(chr(x) for x in (
ValueError: chr() arg not in range(256)
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python27\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\admini~1\\appdata\\local\\temp\\2\\pip-install-xgbxsi\\pdfminer\\setup.py'"'"
'; __file__='"'"'c:\\users\\admini~1\\appdata\\local\\temp\\2\\pip-install-xgbxsi\\pdfminer\\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\admini~1\appdata\local\temp\2\pip-record-mdl997\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
This used to work ... and I have no clue on how to fix that.
Recently pdfminer dropped the support for Python 2.
You can try using pdfminer.six, this is a fork of pdfminer that it supports both Python 2 and 3. However, the support for Python 2 will be dropped at January, 2020, so it will only buy you a few months.
Full disclosure: I am one of the maintainers of pdfminer.six.

Categories

Resources