Error when installing using pip - python

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.

Related

How to install dlib for python on mac?

I'm getting an error when trying to install dlib on Python 3.7 on macOS with
pip3 install dlib
I have installed CMake, so that is not the problem.
I'm getting these error messages:
Failed building wheel for dlib
and
Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/j2/nvk5521j2vn9s1w95_0vlwkm0000gn/T/pip-install-ls2e_3mr/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/j2/nvk5521j2vn9s1w95_0vlwkm0000gn/T/pip-record-hy3hu262/install-record.txt --single-version-externally-managed --compile"
failed with error code 1 in /private/var/folders/j2/nvk5521j2vn9s1w95_0vlwkm0000gn/T/pip-install-ls2e_3mr/dlib/
at the end in red. The reason I need dlib is to install face_recognition.
I think there's more to the error message and it's probably related to CMake, either it's not installed properly or it's not compatible with the pip3 install dlib.
I suggest using Homebrew to install Python3 (which includes pip3) and CMake. Homebrew manages the installation of packages, tools, libraries that might depend on system-related tools, paths, etc. It also prevents you from having to use sudo to install stuff on your system.
Install Homebrew
See the "Install Homebrew" section of https://brew.sh/
Basically:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install Python3 (and pip3) using Homebrew
See https://docs.brew.sh/Homebrew-and-Python
See Homebrew's formula for the latest Python3 (python3.7, python3.8, python3.9)
Basically do one of the following:
$ brew install python#3.7 # or python#3.8 or python#3.9
$ brew install python#3 # get whichever is the latest version
Check Python installation
$ python3 -V
$ python3 -m pip -V
Install CMake using Homebrew
See https://formulae.brew.sh/formula/cmake
Basically:
$ brew install cmake
Check CMake installation
$ brew info cmake
$ cmake --version
Finally, install dlib with pip
$ python3 -m pip install dlib
If you don't want to use Homebrew (for some reason), you can try installing CMake for Mac directly using the installers (dmg or tar.gz) from here: https://cmake.org/download/.
Install Homebrew from here
A bunch of dependencies are needed for dlib:
brew install cmake
brew install boost
brew install boost-python
brew install dlib
pip3 install numpy
pip3 install scipy
pip3 install scikit-image
pip3 install dlib
If this does not work, try:
python3 -m pip install dlib
dlib is dependent on cmake so you need to install that first.
You just need to run following commands on your terminal:
$ brew install cmake
$ pip install cmake
$ brew install dlib
$ pip install dlib
You can install the conda-forge Dlib package by running
conda install -c conda-forge dlib
Conda-forge has made sure to resolve all the dependency conflicts, so I had no issues with the installation. They have pre-built binaries for Windows, Linux, and Mac OS, and Python 2.7 through 3.8. The current package (at the time of this writing) is based on Dlib v19.19.
$ pip3 install --upgrade pip
$ pip3 install global
$ pip3 install cmake
$ pip3 install dlib
$ brew install dlib
$ sudo pip install dlib
The only thing you need to do, I guess, is run pip3 install dlib with sudo.
sudo pip3 install dlib

Error installing uwsgi in virtualenv

I'm trying to install uswgi in a virutal env on linux ubuntu, python 3.5.2
I do
pip install uwsgi
I got this error
Failed building wheel for uwsgi
and at the end of the installing logs
*** uWSGI compiling embedded plugins ***
[thread 0][x86_64-linux-gnu-gcc -pthread] plugins/python/python_plugin.o
[thread 1][x86_64-linux-gnu-gcc -pthread] plugins/python/pyutils.o
In file included from plugins/python/python_plugin.c:1:0:
plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory
compilation terminated.
In file included from plugins/python/pyutils.c:1:0:
plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory
compilation terminated.
----------------------------------------
Command "/home/ubuntu/envflask/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-wthov1ur/uwsgi/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-quiupta5-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/envflask/env/include/site/python3.5/uwsgi" failed with error code 1 in /tmp/pip-build-wthov1ur/uwsgi/
Linux 4.4.0-66-generic x86_64
Python 3.5.2
It is any solution for this? Thanks
You need to install Python3.5 development files, so run this command:
apt-get install python3.5-dev
The above command will install Python 3 headers to build uWSGI from source.
apt-get install build-essential python3-dev
From the uWSGI documentation:
uWSGI is a (big) C application, so you need a C compiler (like gcc or clang) and the Python development headers.
On a Debian-based distro an
apt-get install build-essential python-dev will be enough.
For Python3, just change that to python3-dev.
$ python3 --version
Python 3.5.2
$ pip3 freeze
uWSGI==2.0.15
For anyone with python 3.6 facing the same problem here is the step to solve it :
Get python 3.6 dev tools from this ppa:
sudo add-apt-repository ppa:deadsnakes/ppa
Then update your package list with :
sudo apt-get update
and then install your dev tools with 3.6 version
apt-get install build-essential python3.6-dev
Activate your virtual environment with and then install uwsgi:
pip install uwsgi
Debian have package depending on all supported Python 3 development packages:
apt-get install python3-all-dev
I have faced the same issue. I solve it by following:
sudo apt install libpython3.7-dev
If your python version is 3.6, then use 3.6 instead of 3.7.
After that install uwsgi using pip:
sudo pip install uwsgi
if you faced with the same problem while installing uwsgi under python3.6
just
apt-get install python3.6-dev
In my case uwsgi installed via buildout
NOTE: may be you should add valid ppa
Alternatively, you can use conda to install uwsgi, but make sure to use conda-forge channel:
conda install -c conda-forge uwsgi
You must install python3-devel package:
$ sudo dnf install python3-devel -y
And then install uwsgi module:
$ pip install uwsgi
I was stuck on this one, trying to install uwsgi on Unbuntu in Windows Linux Subsystem.
Although it didn't give permission error, I solved it by running:
sudo pip install uwsgi
For openSUSE (tumbleweed),
I deactivated and deleted my venv
installed python3-devel via yast2
then recreated and activated my venv
and pip install uwsgi
if you want to install uwsgi command, through
curl http://uwsgi.it/install | bash -s default /tmp/uwsgi
mv /tmp/uwsgi to /usr/local what ever
I had a similar issue when installing uwsgi
ibpython3.7m.a’ generated with LTO version 6.0 instead of the expected 8.1.
The default Python was 3.7 and I had to use pip3.8 to solve this problem.
However I have another problem. Running
sudo uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:app
generates the following error:
uwsgi: invalid option -- 'w'
getopt_long() error
I have tried many things, including modular installation
The main problem is that the default uwsgi folder is /usr/bin/uwsgi but when I install using pip3.8 it is not set to default. I couldn't resolve this problem and I switched to fastapi and uvicorn.
I'm still interested to find the solution to my problem.

"failed with error code 1" while installing scipy

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

Error installing pip package on debian / python 3.4

I have python 3.4 compiled from sources on my debian 7.8.
I have already installed some Python packages using pip and virtualenv (django, pillow etc), but i have an error installing python-phonenumbers (https://github.com/daviddrysdale/python-phonenumbers).
I tried it using virtualenv and without, running pip3 install phonenumbers and manually downloading archive and running python3 setup.py install. Every time I get same error:
Command "/usr/local/bin/python3.4 -c "import setuptools, tokenize;
__file__='/tmp/pip-build-ogsbxm_d/phonenumbers/setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__)
.read().replace('\r\n', '\n'), __file__, 'exec'))"
install --record /tmp/pip-98gunm55-record/install-record.txt
--single-version-externally-managed --compile"
failed with error code -9 in /tmp/pip-build-ogsbxm_d/phonenumbers
I tried it on my windows and ubuntu 14.04 - everything ok. How can i fix it?
For Ubuntu 14.04, from Docker image python:3.4.3-slim this combination worked for me:
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y python3.4-dev
sudo apt-get install -y libpq-dev
pip3 install psycopg2
Note build-essential package. It was crucial in my case. Maybe it will help you too.

How to install the library netifaces for Python3 in Ubuntu 12.04?

I made a program in Python3 which uses the package netifaces, I installed it with pip3 in two computers which had Ubuntu 13.04 and Ubuntu 13.10. However, I need to install it in other computer which has Ubuntu 12.04, and here I cannot install pip3 (python3-pip) because it is not on the repositories.
What I did was the next steps:
sudo aptitude install python3-setuptools
sudo easy_install3 pip
And then I had pip3 available. The problem is when I tried to install netifaces with pip3, which gives me next error:
error: command 'gcc' failed with exit status 1
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/netifaces/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gkaftl-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/netifaces
Storing debug log for failure in /home/anubia/.pip/pip.log
If I install netifaces with pip or aptitude or apt-get the program does not recognise the library, because its documents are installed in python2 folders. I even tried to do a symbolic link from python3 folders to them, but it did not work.
Any ideas, please?
Solved!
I had to install the package python3-dev too, then the installation of netifaces from pip3 did not give me an error and now I can use it.
So the whole process (in my case) was:
sudo aptitude install python3-setuptools
sudo easy_install3 pip
sudo aptitude install python3-dev
sudo pip3 install netifaces

Categories