I have Python 2.7.9 on windows 7 64-bits. I'm trying to install scipy using pip. I used pip install scipy but I get the following error :
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\us
ers\\admin\\appdata\\local\\temp\\pip-build-xpl5cw\\scipy\\setup.py';exec(compil
e(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file
__, 'exec'))" install --record c:\users\admin\appdata\local\temp\pip-b68pfc-reco
rd\install-record.txt --single-version-externally-managed --compile" failed with
error code 1 in c:\users\admin\appdata\local\temp\pip-build-xpl5cw\scipy
I searched on google and stackoverflow for solutions but nothing worked. I tried upgrading pip and it didn't work too.
Here are my installed packages and their versions :
httplib2 (0.9.1)
nltk (3.0.3)
nose (1.3.7)
numpy (1.9.2)
pip (7.0.3)
pytz (2015.4)
scikit-learn (0.16.1)
setuptools (17.1.1)
six (1.9.0)
twilio (4.4.0)
wheel (0.24.0)
I'm on Ubuntu 14.04. I tried installing through pip which kept on failing with error code 1 or took forever to finish (never finished actually!).
However, the following command worked without a hitch:
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
Reference: http://www.scipy.org/install.html
On Windows, you'll need to use the unofficial precompiled binaries:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Select the version matching your architecture and Python version.
Installing setuptools made it work for me (Mac OS)
pip install -U pip setuptools
I also had the same error when installing scipy.
Then I downloaded and installed MiniConda. And then I used the below command to install pytables.
conda install -c conda-forge scipy
Please refer the below screenshot.
On windows you can check below command:
python -m pip install psycopg2
Related
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using
python3 -m pip install scipy
I also tried installing everything from brew, and import scipy works, but using it gives a seg fault. I have installed ARM versions of lapack and openblas, but this does not fix the problem.
Has anyone succeeded? (I am interested in running it natively, not through Rosetta).
It's possible to install on regular arm64 brew python, you need to compile it yourself.
If numpy is already installed (from wheels) you'll need to uninstall it:
pip3 uninstall -y numpy pythran
I had to compile numpy, which requires cython and pybind11:
pip3 install cython pybind11
Then numpy can be compiled:
pip3 install --no-binary :all: --no-use-pep517 numpy
Scipy needs pythran (this should happen after installing numpy):
pip3 install pythran
Then we need to compile scipy itself, it depends on fortran and BLAS/LACK:
brew install openblas gfortran
Tell scipy where it can find this library:
export OPENBLAS=/opt/homebrew/opt/openblas/lib/
Then finally compilescipy:
pip3 install --no-binary :all: --no-use-pep517 scipy
This one worked for me after wasting hours:
pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy
This solution worked on my M1 machine with pyenv:
brew install openblas
OPENBLAS="$(brew --prefix openblas)" pip install numpy scipy
You can install miniforge from https://github.com/conda-forge/miniforge#miniforge3
and then install those packages with,
conda install numpy scipy matplotlib
For me the easiest solutions:
brew install scipy
Probably good idea to edit the PATH, so the homebrew version will be the default.
I managed to get scipy installed on Apple Silicon. I mostly followed the instructions by lutzroeder here: https://github.com/scipy/scipy/issues/13409
Those instructions weren't successful for me, but running 'pip3 install scipy' worked afterwards. I think this fixed the problem for me:
/opt/homebrew/bin/brew install openblas
export OPENBLAS=$(/opt/homebrew/bin/brew --prefix openblas)
export CFLAGS="-falign-functions=8 ${CFLAGS}"
For those who need it for short-term purposes and don't want too much hustle - it seems to work with python 3.6.4 and scipy 1.5.4 out of the box (Big Sur 11.5.2, M1 chip).
In addition, if someone has this error message>
########### CLIB COMPILER OPTIMIZATION ###########
Platform :
Architecture: aarch64
Compiler : clang
CPU baseline :
Requested : 'min'
Enabled : none
Flags : none
Extra checks: none
CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : none
Generated : none
CCompilerOpt.cache_flush[809] : write cache to path
I found this solution before compile numpy and scipy
Analysis of reasons:
From the above error message, you can see that the last error shows that clang has an error, so it is speculated that it should be an error caused by the compiler, because the new version of the xcode command tool uses the arm version of the compilation method by default, and if we want to use For x86 architecture, we need to manually set the specific architecture through environment variables.
export ARCHFLAGS="-arch x86_64"
example:
3c790c45799ec8c598753ebb22/build/temp.macosx-10.14.6-arm64-3.8/ccompiler_opt_cache_clib.py
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/daniel_edu/Projects/PERSONAL/great_expectation_demo/.env/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/c_b9kh2x1px7vl5683rwz8fr0000gn/T/pip-install-y8alaej_/numpy_3d813a3c790c45799ec8c598753ebb22/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/c_b9kh2x1px7vl5683rwz8fr0000gn/T/pip-install-y8alaej_/numpy_3d813a3c790c45799ec8c598753ebb22/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/zb/c_b9kh2x1px7vl5683rwz8fr0000gn/T/pip-record-q9vraevr/install-record.txt --single-version-externally-managed --compile --install-headers /Users/daniel_edu/Projects/PERSONAL/great_expectation_demo/.env/include/site/python3.8/numpy Check the logs for full command output.
(.env) ➜ great_expectation_demo git:(master) ✗ export ARCHFLAGS="-arch x86_64"
(.env) ➜ great_expectation_demo git:(master) ✗ pip install --no-binary :all: --no-use-pep517 numpy
Collecting numpy
Using cached numpy-1.21.5.zip (10.7 MB)
Preparing metadata (setup.py) ... done
Skipping wheel build for numpy, due to binaries being disabled for it.
Installing collected packages: numpy
Running setup.py install for numpy ... done
Successfully installed numpy-1.21.5
What version of scipy you're trying to install?
To me running on Macbook air M1, I needed to increase the version from scipy==1.5.1 to scipy==1.7.3, so I guess you should use 1.7.3 version or above it and all will be fine...
pip install -Iv scipy==1.7.3
Or just add in your file requirements.txt this line:
scipy==1.7.3
The following worked for me.
I'm currently using Python 3.10.8, installed using brew.
And currently, when installing numpy==1.23.4, setuptools < 60.0.0 is required.
I'm using (brew --prefix)/bin/python3 -m pip for explicitly calling the pip from python 3.10 installed by brew.
Here are the versions I've just installed.
# python 3.10.8
# pip 22.3
# setuptools 59.8.0
# wheel 0.37.1
# numpy 1.23.4
# scipy 1.9.3
# pandas 1.5.1
# scikit-learn 1.1.3
# seaborn 0.12.1
# statsmodels 0.13.2
# gcc 12.2.0
# openblas 0.3.21
# gfortran 12
# pybind11 2.10.0
# Cython 0.29.32
# pythran 0.12.0
Here are the steps I followed:
# setuptools < 60.0.0 is required for numpy==1.23.4 in Python 3.10.8
$(brew --prefix)/bin/python3 -m pip install --upgrade pip==22.3 setuptools==59.8.0 wheel==0.37.1
# uninstall numpy and pythran first
$(brew --prefix)/bin/python3 -m pip uninstall -y numpy pythran
# uninstall scipy
$(brew --prefix)/bin/python3 -m pip uninstall -y scipy
# install prerequisites (with brew)
brew install gcc
brew install openblas
brew install gfortran
# set environment variables for compilers to find openblas
export LDFLAGS="-L/opt/homebrew/opt/openblas/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openblas/include"
# install the prerequisites (with pip)
$(brew --prefix)/bin/python3 -m pip install pybind11
$(brew --prefix)/bin/python3 -m pip install Cython
# install numpy
$(brew --prefix)/bin/python3 -m pip install --no-binary :all: numpy
# install pythran after installing numpy, before installing scipy
$(brew --prefix)/bin/python3 -m pip install pythran
# install scipy
export OPENBLAS="$(brew --prefix)/opt/openblas/lib/"
$(brew --prefix)/bin/python3 -m pip install scipy
# install pandas
$(brew --prefix)/bin/python3 -m pip install pandas
# install scikit-learn
$(brew --prefix)/bin/python3 -m pip install scikit-learn
# install seaborn
$(brew --prefix)/bin/python3 -m pip install seaborn
# install statsmodels
$(brew --prefix)/bin/python3 -m pip install statsmodels
I use conda install scipy to resolve this problem. Conda have a custom version of scipy for Apple M1. Update macOS to 12 if you don't want to use Conda.
According to this Github issue, Scipy doesn't work on MacOS 11 (Big Sur). If none of these solutions are working for you I'd suggest updating your OS.
SciPy maintainer here.
SciPy is now distributed for M1, on both conda and pip. You need at least macOS 12.0 (Monterey) and Python >= 3.8. Our support for macOS is good, meaning you should not need to do anything special or compile yourself unless you want to use a development version or older macOS versions.
If you need to compile, only use our guides (e.g. https://scipy.github.io/devdocs/dev/contributor/building.html#building-from-sources). There are tons of moving pieces and doing something else might work today, but not tomorrow.
Avoid using pip to compile SciPy. Use our developer script python dev.py build after having followed the guides I linked to setup system dependencies for your platform.
Do NOT use brew to install a Python package, use an environment. brew is great to install system dependencies or other dev tools, but should not be used to install Python packages. Down the road this is a recipe for trouble.
import face_recognition
image = face_recognition.load_image_file("My_Image.png")
face_locations = face_recognition.face_locations(image)
print("I found {} face(s) in this photograph.".format(len(face_locations)
When I run above code, I've found following error message.
Traceback (most recent call last): File "sample.py", line 1, in
import face_recognition
And I've checked that I've found following error message when I've installed face_recognition library.
pip install face_recognition
RuntimeError:
*******************************************************************
CMake must be installed to build the following extensions: dlib
*******************************************************************
----------------------------------------
Failed building wheel for dlib
Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib, Pillow, numpy, face-recognition-models, face-recognition
Command "/usr/local/opt/python/bin/python3.7 -u -c "import setuptools,
tokenize;file='/private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-install-gk35rom0/dlib/setup.py';f=getattr(tokenize,
'open', open)(file);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, file, 'exec'))" install
--record /private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-record-3enjhgfq/install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in
/private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-install-gk35rom0/dlib/
My python version is Python 3.7.1 and pip is pip 19.0.3 from /Library/Python/2.7/site-packages/pip (python 2.7)
Install Cmake with:
sudo apt install cmake
And for python3 don't use pip alone, use pip3 to install future python3 modules:
pip3 install face_recognition
I was facing same issue, but then it solved through following steps:
Step 1: Download Microsoft Visual Studio 2015 or newer (check if build tools are enough).
Step 2: Download cmake (pip install cmake)
Step 3: Install dlib (pip install dlib)
Step 4: Install face-recognition (pip install face-recognition)
But install it in specific environment that will be used later for face_recognition code (In conda: activate environment name).
Reference:
https://www.youtube.com/watch?v=oSQAXMgwLFo
For everyone who still found error when installing this step, I will give a brief requirements for your system.
Python3.9 [the most important]
Download dlib (this)
Next, after the above requirement fulfilled, do this.
pip install cmake
pip install dlib-19.23.0-cp39-cp39-win_amd64.whl
pip install opencv-python
pip install face_recognition
Bonus, in my case, I got error with the pillow library so you need to reinstall it, using these steps.
pip uninstall pillow
pip install Pillow
Well, I hope this will help, thanks.
This worked for me...
pip install CMake==3.22.2
pip install dlib==19.18.0
pip install face_recognition
I am running ubuntu 16. I have both python 2.7 and 3.5 installed. I want to install cx_freeze latest version for python3. I downloaded the package from their website but couldn't run the setup.py file as it always gave me errors. Also i have installed pip3, but it still doesn't work for me. all the answers online are for older version of cx_freeze so a fresh answer for the new version will be helpful.
I install and upgrade pip3 with:
sudo -H install --upgrade pip
then I try to install cx_freeze with:
pip3 install cx_Freeze .
then i get the following errors:
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ngco46uq/cx-Freeze/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-q3n3cd2r-record/install-record.txt --single-version-externally-managed --compile"
failed with error code 1 in /tmp/pip-build-ngco46uq/cx-Freeze/
also anyone can tell me any other method to do so ?
Try installing Pip3 using :
sudo apt-get install python3-pip
If you have Python 2.7, you can try alternatives like py2exe
I am pretty new to python. I want to use KMean code, and I want to install scikit-learn or sklearn.
I used this code to attempt install these packages:
pip install -U sklearn
pip install -U scikit-learn
But I got this error:
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_reihaneh/sklearn/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-89YQB7-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_reihaneh/sklearn
Storing debug log for failure in /home/reihaneh/.pip/pip.log
What is the cause of the problem?
pip install -U <package>, short for pip install --upgrade <package>, will upgrade <package> to the most recent stable version in the pip repo.
pip install <package> will install the most recent stable version of <package> in the pip repo.
The difference is upgrading vs. installing. You want the latter.
scikit-learn requires scipy and numpy, so here are the commands you should issue:
pip install numpy
pip install scipy
pip install scikit-learn
If you already have any of the dependencies, just plug in a -U between pip install and the package name.
If you're using Python 3.x, replace pip with pip3.
Not sure whats going on here but I am getting an error every time I try to install something using pip I get the following error:
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-build-V4hy8S/PySocks/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-bIOl7C-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-build-V4hy8S/PySocks
Try
sudo pip install -U setuptools
If this doesn't solve your problem then
Firstly, you need the python-dev package because Pillow needs compile headers defined.
sudo apt-get install python-dev
On Ubuntu 14.04 you need few extra packages to get pillow working. Install all of them with the command:
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
Seems that your PiP can't access Setuptools as per the "import setuptools" in the error. Try the below first then try running your pip install again.
sudo pip install -U setuptools
Solution from Github Issue
Launch the command prompt with 'run as administrator' rights before installing.
then try the script -
pip install package_name_here
if error is thrown,then import setup tools
pip install -U setuptools
if again error thrown then upgrade your pip installer using this script(personally worked for me)
python -m pip install --upgrade pip
I had the same problem on Windows Git Bash but installing setuptools did not fix it. Then I noticed another error message further up:
building 'twisted.test.raiser' 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
That link was dead but ultimately this page had a link to the correct download: https://wiki.python.org/moin/WindowsCompilers
I installed Microsoft Build Tools for Visual Studio 2017 and that resolved it.
It majorly depends on the type of packages you suppose to install.
Frequently its failing due to the missing of
libsasl2-dev a package for authentication abstraction library which use in the Ubuntu version
First, install:
sudo apt-get install libsasl2-dev
then run:
pip install <<\package_name>>
first run as superuser:
sudo su
then :
pip install PyOpenGL PyOpenGL_accelerate
If you get this error on Windows, like I did, then just run the command-line tool (cmd.exe or Powershell) as Administrator and try again.