I am trying to install Scikit by running:
pip install scikit-learn
When I run it, I get this message:
Collecting scikit-learn
Using cached scikit-learn-0.18.1.tar.gz
Installing collected packages: scikit-learn
Running setup.py install for scikit-learn ... error
Complete output from command c:\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\USER\\AppData\\Local\\Temp\\pip-build-3080ikpy\\scikit-learn\\setup.py';f=getatt
r(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\USER\AppData\Local\Temp\pip-04zx4iu6-record\i
nstall-record.txt --single-version-externally-managed --compile:
Partial import of sklearn during the build process.
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Temp\pip-build-3080ikpy\scikit-learn\setup.py", line 149, in get_scipy_status
import scipy
File "c:\python36\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER\AppData\Local\Temp\pip-build-3080ikpy\scikit-learn\setup.py", line 270, in <module>
setup_package()
File "C:\Users\USER\AppData\Local\Temp\pip-build-3080ikpy\scikit-learn\setup.py", line 260, in setup_package
.format(scipy_req_str, instructions))
ImportError: Scientific Python (SciPy) is not installed.
scikit-learn requires SciPy >= 0.9.
Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html
Which seems to ask me to install Scipy, however I already have Scipy installed, and indeed if I run
pip install scipy
I get
Requirement already satisfied: scipy in c:\python36\lib\site-packages
Requirement already satisfied: numpy>=1.8.2 in c:\python36\lib\site-packages (from scipy)
Your install shows this: from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl ImportError: cannot import name 'NUMPY_MKL'
So you need to do a few things. Get the right SciPy: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
Get the right NumPy: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Get the right SciKit Learn: http://www.lfd.uci.edu/~gohlke/pythonlibs/#sci-kitlearn
Now do pip uninstall each of your other packages. Then do pip install the wheels you downloaded at those links provided - NumPy 1st, SciPy 2nd, then Ski-kitlearn last. That should then solve your issue. Note at those links you're downloading the files with cp36‑cp36m‑win32.whlor cp36‑cp36m‑win_amd64.whl depending on if you have 32bit or 64bit Python installed.
Related
I have a docker image that I need to install openCV in it and from yesterday it started to fail because it cannot find the "skbuild" module:
Step 12/24 : RUN pip install opencv-python opencv-contrib-python
---> Running in a0f746a23aed
Collecting opencv-python
Downloading https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.tar.gz (88.9MB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-cciracwm/opencv-python/setup.py", line 9, in <module>
import skbuild
ModuleNotFoundError: No module named 'skbuild'
And on the host also I cannot find that module and pip search is either return nothing or returns a server error:
sudo pip3 search skbuild
WARNING: The directory '/home/ali/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 216, in _main
status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/search.py", line 60, in run
pypi_hits = self.search(query, options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/search.py", line 80, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "/usr/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python3.6/xmlrpc/client.py", line 1452, in __request
verbose=self.__verbose
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/xmlrpc.py", line 45, in request
return self.parse_response(response.raw)
File "/usr/lib/python3.6/xmlrpc/client.py", line 1342, in parse_response
return u.close()
File "/usr/lib/python3.6/xmlrpc/client.py", line 656, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -32403: 'server error; service unavailable'>
Is this because their server has some problems or it is related to my pip?
Update
I tried it on different python and pip versions, python versions 3.6 and 3.7 and pip version 19.12 and 20.2.2 and 9.0.1 (the one inside image).
Update 2
I added pip install scikit-build one step before opencv installation but I get another error related to cmake:
Step 12/25 : RUN pip install scikit-build
---> Running in afe0c5c0fca0
Collecting scikit-build
Downloading https://files.pythonhosted.org/packages/78/c9/7c2c7397ea64e36ebb292446896edcdecbb8c1aa6b9a1a32f6f67984c3df/scikit_build-0.11.1-py2.py3-none-any.whl (72kB)
Collecting packaging (from scikit-build)
Downloading https://files.pythonhosted.org/packages/46/19/c5ab91b1b05cfe63cccd5cfc971db9214c6dd6ced54e33c30d5af1d2bc43/packaging-20.4-py2.py3-none-any.whl
Requirement already satisfied: wheel>=0.29.0 in /usr/lib/python3/dist-packages (from scikit-build)
Collecting distro (from scikit-build)
Downloading https://files.pythonhosted.org/packages/25/b7/b3c4270a11414cb22c6352ebc7a83aaa3712043be29daa05018fd5a5c956/distro-1.5.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=28.0.0; python_version >= "3" in /usr/lib/python3/dist-packages (from scikit-build)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from packaging->scikit-build)
Collecting pyparsing>=2.0.2 (from packaging->scikit-build)
Downloading https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl (67kB)
Installing collected packages: pyparsing, packaging, distro, scikit-build
Successfully installed distro-1.5.0 packaging-20.4 pyparsing-2.4.7 scikit-build-0.11.1
Removing intermediate container afe0c5c0fca0
---> 533658ddf26d
Step 13/25 : RUN pip install opencv-python opencv-contrib-python
---> Running in 0f2c03bc042a
Collecting opencv-python
Downloading https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.tar.gz (88.9MB)
Collecting opencv-contrib-python
Downloading https://files.pythonhosted.org/packages/48/98/05bd8e00c71b66c4e7847cc051cac404191d904df58b51a7dcc3767ff747/opencv_contrib_python-4.2.0.34-cp37-cp37m-manylinux1_x86_64.whl (34.2MB)
Collecting numpy>=1.14.5 (from opencv-python)
Downloading https://files.pythonhosted.org/packages/3d/d1/90cd7e0b27ee86d77f5386d38b74520486100286d50772377791b6ef22ff/numpy-1.19.1-cp37-cp37m-manylinux1_x86_64.whl (13.4MB)
Building wheels for collected packages: opencv-python
Running setup.py bdist_wheel for opencv-python: started
Running setup.py bdist_wheel for opencv-python: finished with status 'error'
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-w49xv99a/opencv-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpycj03zlwpip-wheel- --python-tag cp37:
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/skbuild/setuptools_wrap.py", line 560, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py", line 95, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py", line 82, in get_cmake_version
"Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)
Problem with the CMake installation, aborting build. CMake executable is cmake
----------------------------------------
Failed building wheel for opencv-python
Running setup.py clean for opencv-python
Failed to build opencv-python
Installing collected packages: numpy, opencv-python, opencv-contrib-python
Found existing installation: numpy 1.13.3
Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /usr
Running setup.py install for opencv-python: started
Running setup.py install for opencv-python: finished with status 'error'
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-w49xv99a/opencv-python/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-maky1uyw-record/install-record.txt --single-version-externally-managed --compile:
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/skbuild/setuptools_wrap.py", line 560, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py", line 95, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py", line 82, in get_cmake_version
"Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)
Problem with the CMake installation, aborting build. CMake executable is cmake
If you read the opencv-python package FAQ in PyPI, it clearly provides an answer for this specific issue: you must run pip install --upgrade pip. Check pip version afterwards with pip -V.
This is because your pip is too old to understand the new manylinux2014 package format and tries to compile from source. That will also fail because pip is too old to understand how to use pyproject.toml to install build dependencies such as scikit-build.
Another issue I'm spotting is that you install both opencv-python and opencv-contrib-python. You should not do this. It's also explained in the PyPI page of the packages. Most likely you should be using just opencv-contrib-python-headless package since you are using Docker and I assume you do not use the GUI functionalities of OpenCV.
just update the pip and it will work
python -m pip install --upgrade pip
Just update pip.
If you use python3 then:
pip3 install --upgrade pip
pip3 install opencv-python
skbuild is for Scikit-build.
Install it using pip:
As for windows: pip install scikit-build
After the succesfull installation:
pip install cmake
Since I have python3 installed, I had to use
python3 -m pip install --upgrade pip
11/may/2021: faced same issue on a fresh ubuntu18 virtualbox image. this worked for me
sudo -H pip3 install --upgrade pip
pip3 install opencv-python
I also had the error, in my case when executing
python3.7 -m pip install --user opencv-python in order to get catkin_make -j8 working again in a ROS project. Thus, Docker is not needed to get the error.
First the details:
Collecting opencv-python
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/30/46/821920986c7ce5bae5518c1d490e520a9ab4cef51e3e54e35094dadf0d68/opencv-python-4.4.0.46.tar.gz (88.9MB)
100% |████████████████████████████████| 88.9MB 17kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-8jky5692/opencv-python/setup.py", line 9, in <module>
import skbuild
ModuleNotFoundError: No module named 'skbuild'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-8jky5692/opencv-python/
Just documenting what I did to solve it:
python -m pip install --user opencv-python gives me /usr/bin/python: No module named pip
sudo apt install python-pip (in addition to the already existing sudo apt install python3-pip installation for pip3)
python -m pip -V now gives me pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
pip -V gives me pip 20.3.3 from /home/MYUSERNAME/.local/lib/python3.6/site-packages/pip (python 3.6) (because apt-get installs a standard 3.6, independently from existing python versions)
sudo apt-get update && sudo apt-get install cmake libopenmpi-dev python3.7-dev zlib1g-dev (not sure if this step is needed)
pip install opencv-python WORKING
catkin_make -j8 in my catkin workspace in the Python base environment WORKING
Additional hints for the cmake error that is mentioned in the Update 2
This cmake error is perhaps due to a corrupted workspace during or after catkin_make install:
I had a similar cmake error when I executed the catkin_make command inside my Python virtual environment. When I changed back to the base environment (using deactivate), catkin_make ran through. This is probably due to dependency issues in the virtual environment, perhaps also because of the version that is used when you use standard python -m that is used by some internal scripts, see one of the bullet points above. I had to assign python2.7 to the python -m pip -V pip version, probably because ROS gazebo needed 2.7.
Most promising (if this is a catkin issue): simply remove catkin and install it again, see Error 2 Invoking "make -j4 -l4" failed.
Perhaps also see Invoking "cmake" failed.
I had a similar problem and what finally worked was to change from python:3-alpine to python:3.8-slim and install python and openCV similar to what has been done in the selected answer here: Minimal SciPy Dockerfile
If non of these answers works for you try:
pip3 install opencv-python-headless
with python3 you need to use pip3
trying to install the cloudant module on a raspberry pi ver 1 rev b using the instructions from IBM's web page.
first: git clone https://github.com/IBM-Cloud/get-started-python
then: cd get-started-python
finally: pip install -r requirements.txt
I want to use the cloudant module with python 2.7 I've read about the environment variable possibly being an issue, but honestly i'm lost. I've read many posts about problems installing, but so far nothing works...
I get the following error message:
pi#rpi-2:~/hms/get-started-python $ pip install -r requirements.txt
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: Flask>=1.0.0 in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 1)) (1.0.2)
Collecting cloudant==2.13.0
Using cached cloudant-2.13.0.tar.gz (60 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-d8SSO0/cloudant/setup.py'"'"'; __file__='"'"'/tmp/pip-install-d8SSO0/cloudant/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-7Btkkf
cwd: /tmp/pip-install-d8SSO0/cloudant/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-d8SSO0/cloudant/setup.py", line 33, in <module>
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
UPDATE:
so this is my code:
from cloudant.client import cloudant
running my code using python3 code.py I get the error message"
Traceback (most recent call last):
File "code.py", line 1, in <module>
from cloudant.client import cloudant
ModuleNotFoundError: No module named 'cloudant'
While I don't fully understand why changing my import statement to from cloudant import Cloundant fixes the issue...
Parameter encoding was added to open() in Python 3.0. This code in setup.py is Python3-only despite the packages declares compatibility with Python2. Please note they provide wheels only for Python3.
Either using encoding is a bug or declaring compatibility with Python2 is a bug. Which one is for the authors to decide. Report the problem and let's them to resolve.
Or try Python3.
I tried to install a package folium into Jupyter Notebook. I had to try many methods, such as add system path, upgrade pip, install setuptools but I cannot make it. My laptop is Macbook Pro, system: Catalina 10.15.3, Jupyter Notebook from Anaconda. Python version: 3.7.4
System.exectutable:
'/opt/anaconda3/bin/python'
System path:
['/Users/scott/Documents/Untitled Folder',
'/opt/anaconda3/lib/python37.zip',
'/opt/anaconda3/lib/python3.7',
'/opt/anaconda3/lib/python3.7/lib-dynload',
'',
'/opt/anaconda3/lib/python3.7/site-packages',
'/opt/anaconda3/lib/python3.7/site-packages/aeosa',
'/opt/anaconda3/lib/python3.7/site-packages/IPython/extensions',
'/Users/scott/.ipython']
The code I wrote is:
import numpy as np
import pandas as pd
import collections
import re
import matplotlib.pyplot as plt
import matplotlib
from collections import OrderedDict
from math import ceil
#!python3 -m pip install folium --user
#!python3 -m pip install branca --user
#!python3 -m pip install jinja2 --user
#!python3 -m pip install requests --user
#!pip install --user scipy
#!python -m pip install --upgrade pip
import scipy
#import branca
! pip install --user folium
import tqdm
import folium
However, I got such error:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting folium
Using cached folium-0.8.3-py2.py3-none-any.whl (87 kB)
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from folium) (1.12.0)
Collecting jinja2
Using cached Jinja2-2.11.1-py2.py3-none-any.whl (126 kB)
Requirement already satisfied: numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from folium) (1.8.0rc1)
Collecting requests
Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting branca>=0.3.0
Using cached branca-0.4.0.tar.gz (41 kB)
ERROR: Command errored out with exit status 1:
command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/setup.py'"'"'; __file__='"'"'/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/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/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/pip-egg-info
cwd: /private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/zm/pks1_crj5d7d7wp4x_4sr5rm0000gn/T/pip-install-r8yciP/branca/setup.py", line 41
print(error, file=sys.stderr) # noqa
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-201-2c07c456259d> in <module>
17 get_ipython().system(' pip install --user folium')
18 import tqdm
---> 19 import folium
ModuleNotFoundError: No module named 'folium'
I had confused with this error for days, could anyone help me? Thanks in advance!
Looks like you're trying to work in an anaconda 3.7 environment, but your error message is complaining about being python 2.7 and it's complaining it cannot find folium.
Did you somehow pip install the folium module while working outside your anaconda 3.7 environment?
Maybe you could try the conda navigator tool and grab the folium package that way...
I have a python project that I have packaged locally as a wheel, and I want to install this wheel in a virtual environment in a docker container, based off python:alpine3.7. My problem is that sometimes i works, and sometimes it fails to resolve the dependencies in the wheel, seemingly at random.
The dependencies for the wheel is:
_install_requires = [
'numpy>=1.15.0',
'pandas>=0.21.0',
'scipy>=1.0.0',
'scikit-learn>=0.19.2'
]
And my dockerfile is as follows:
FROM python:alpine3.7
# install dependencies
# the lapack package is only in the community repository
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk --update add --no-cache --virtual .build-deps \
gcc \
freetype-dev
RUN apk add --update lapack-dev python py-pip python-dev &&\
apk add --update linux-headers
# Install dependencies
RUN apk add --no-cache --virtual .build-deps \
gfortran \
musl-dev \
g++ \
make &&\
ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN pip install --upgrade pip && pip install virtualenv
RUN virtualenv -p python3 ./venv
ADD dist/project-as-wheel-py3-none-any.whl .
RUN . ./venv/bin/activate && pip install ./project-as-wheel-py3-none-any.whl
When building the docker container, sometimes it fails, with a typical log being:
Processing /project-as-wheel-py3-none-any.whl
Collecting scikit-learn>=0.19.2 (from project-as-wheel==0.2.6)
Downloading https://files.pythonhosted.org/packages/25/b6/454cf208be93efa3db50ce06b732328c57ede005d1dcfa71d9a1548530b0/scikit-learn-0.19.2.tar.gz (9.7MB)
Collecting pandas>=0.21.0 (from project-as-wheel==0.2.6)
Downloading https://files.pythonhosted.org/packages/3e/56/82c4d4c049294f87ebd05b65fdcbc9ed68bd23fb0a7e4469caf9a75d199f/pandas-0.23.3.tar.gz (10.5MB)
Collecting numpy>=1.15.0 (from project-as-wheel==0.2.6)
Downloading https://files.pythonhosted.org/packages/3a/20/c81632328b1a4e1db65f45c0a1350a9c5341fd4bbb8ea66cdd98da56fe2e/numpy-1.15.0.zip (4.5MB)
Collecting scipy>=1.0.0 (from project-as-wheel==0.2.6)
Downloading https://files.pythonhosted.org/packages/07/76/7e844757b9f3bf5ab9f951ccd3e4a8eed91ab8720b0aac8c2adcc2fdae9f/scipy-1.1.0.tar.gz (15.6MB)
Collecting python-dateutil>=2.5.0 (from pandas>=0.21.0->project-as-wheel==0.2.6)
Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
Collecting pytz>=2011k (from pandas>=0.21.0->project-as-wheel==0.2.6)
Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
Collecting six>=1.5 (from python-dateutil>=2.5.0->pandas>=0.21.0->project-as-wheel==0.2.6)
Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Building wheels for collected packages: scikit-learn, pandas, numpy, scipy
Running setup.py bdist_wheel for scikit-learn: started
Running setup.py bdist_wheel for scikit-learn: finished with status 'error'
Complete output from command /venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/scikit-learn/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-ogmdp3dv --python-tag cp37:
Partial import of sklearn during the build process.
Traceback (most recent call last):
File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 168, in get_numpy_status
import numpy
ModuleNotFoundError: No module named 'numpy'
Traceback (most recent call last):
File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 148, in get_scipy_status
import scipy
ModuleNotFoundError: No module named 'scipy'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 269, in <module>
setup_package()
File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 249, in setup_package
.format(numpy_req_str, instructions))
ImportError: Numerical Python (NumPy) is not installed.
scikit-learn requires NumPy >= 1.8.2.
Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html
----------------------------------------
Failed building wheel for scikit-learn
Running setup.py clean for scikit-learn
Running setup.py bdist_wheel for pandas: started
Running setup.py bdist_wheel for pandas: still running...
Running setup.py bdist_wheel for pandas: still running...
Running setup.py bdist_wheel for pandas: still running...
Running setup.py bdist_wheel for pandas: still running...
Running setup.py bdist_wheel for pandas: still running...
Running setup.py bdist_wheel for pandas: still running...
Running setup.py bdist_wheel for pandas: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/8d/e7/58/7a882c73419e95e6709d925abb4b56c719c9be59ef826fe01c
Running setup.py bdist_wheel for numpy: started
Running setup.py bdist_wheel for numpy: still running...
Running setup.py bdist_wheel for numpy: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/77/d2/00/03180c22fc40b6f17f6a5c6ea0fa1689734a9cf4cf54179a1c
Running setup.py bdist_wheel for scipy: started
Running setup.py bdist_wheel for scipy: finished with status 'error'
Complete output from command /venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-83ktidr8 --python-tag cp37:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-439jjmrz/scipy/setup.py", line 474, in <module>
setup_package()
File "/tmp/pip-install-439jjmrz/scipy/setup.py", line 450, in setup_package
from numpy.distutils.core import setup
ModuleNotFoundError: No module named 'numpy'
----------------------------------------
Failed building wheel for scipy
Running setup.py clean for scipy
Complete output from command /venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
`setup.py clean` is not supported, use one of the following instead:
- `git clean -xdf` (cleans all files)
- `git clean -Xdf` (cleans all versioned files, doesn't touch
files that aren't checked into the git repo)
Add `--force` to your command to use it anyway if you must (unsupported).
----------------------------------------
Failed cleaning build dir for scipy
Successfully built pandas numpy
Failed to build scikit-learn scipy
Installing collected packages: scikit-learn, six, python-dateutil, pytz, numpy, pandas, scipy, project-as-wheel
Running setup.py install for scikit-learn: started
Running setup.py install for scikit-learn: finished with status 'error'
Complete output from command /venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/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 /tmp/pip-record-dwajrs1d/install-record.txt --single-version-externally-managed --compile --install-headers /venv/include/site/python3.7/scikit-learn:
Partial import of sklearn during the build process.
Traceback (most recent call last):
File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 168, in get_numpy_status
import numpy
ModuleNotFoundError: No module named 'numpy'
Traceback (most recent call last):
File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 148, in get_scipy_status
import scipy
ModuleNotFoundError: No module named 'scipy'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 269, in <module>
setup_package()
File "/tmp/pip-install-439jjmrz/scikit-learn/setup.py", line 249, in setup_package
.format(numpy_req_str, instructions))
ImportError: Numerical Python (NumPy) is not installed.
scikit-learn requires NumPy >= 1.8.2.
Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html
----------------------------------------
Command "/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-439jjmrz/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 /tmp/pip-record-dwajrs1d/install-record.txt --single-version-externally-managed --compile --install-headers /venv/include/site/python3.7/scikit-learn" failed with error code 1 in /tmp/pip-install-439jjmrz/scikit-learn/
What confuses me is that pip manages to install numpy and pandas, then fails to install scipy claiming there's "No module named 'numpy'".
Edit: A TL;DR on the log is:
pip tries to install scikit-learn, fails as numpy is not installed.
pip tries to install pandas, succeeds.
pip tries to install numpy, succeeds.
pip tries to install scipy, fail as numpy is not installed (however it was successfully installed in step 3 above!).
pip declares that it succeeded in installing pandas and numpy, but failed to install scikit-learn and scipy.
pip tries again to install scipy, fails again, complaining that numpy is not installed.
pip gives up.
Edit2: Based on Nuts suggestion I changed the relevant line in the dockerfile to
RUN . ./venv/bin/activate && pip install numpy && pip install scipy && pip install ./project-as-wheel-py3-none-any.whl
Not very satisfactory, as I can't get the version requirements out of setup.py, but it works.
Change requirements to this
_install_requires = [
'numpy>= 1.8.2',
'pandas>=0.21.0',
'scipy>=1.0.0',
'scikit-learn>=0.19.2'
]
I'm using Linux AMI on Amazon EC2 and I would like to install numpy and scipy. In theory, it should be quite straightforward, but I'm runnign into problems.
Here are my steps:
> sudo alternatives --set python /usr/bin/python3.4
> sudo virtualenv -p python3.4 my_env
> sudo chmod -R 777 my_env
> . my_env/bin/activate
> pip install numpy
Installing numpy returns:
Collecting numpy
Using cached numpy-1.10.1.tar.gz
Installing collected packages: numpy
Running setup.py install for numpy
Successfully installed numpy
But it does not seems to work, because running pip freeze and pip list does not show any trace of numpy. The fact that I'm missing the package is obvious when I try to run pip install scipy:
Collecting scipy
Using cached scipy-0.16.1.tar.gz
Collecting numpy>=1.6.2 (from scipy)
Using cached numpy-1.10.1.tar.gz
Installing collected packages: numpy, scipy
Running setup.py install for numpy
ImportError: No module named 'numpy' Running setup.py install for scipy
Complete output from command /usr/lib/python3.4/my_env/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-wq1cn43p/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mjftl3bs-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/lib/python3.4/my_env/include/site/python3.4/scipy:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-wq1cn43p/scipy/setup.py", line 253, in <module>
setup_package()
File "/tmp/pip-build-wq1cn43p/scipy/setup.py", line 241, in setup_package
from numpy.distutils.core import setup
ImportError: No module named 'numpy'
I have the lastest pip version, 7.1.2.
When you set up your virtualenv to use python3 you also have to use pip3
virtualenv -p python3.4 env
source env/bin/activate
pip3 install numpy