Pandas Seaborn Install - python-2.7

On Ubuntu 12.04 LTS running Python 2.7 I'm getting an install error from attempting to add the great looking Seaborn plotting package to my existing Pandas environment which is running fine.
Here's a snippet from the console containing the errors:
~$ pip install seaborn
running install_lib
creating /usr/local/lib/python2.7/dist-packages/seaborn
error: could not create '/usr/local/lib/python2.7/dist-packages/seaborn':
Permission denied
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tm/pip_build_moj0/seaborn/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-LvVao5-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_mojo/seaborn
Storing debug log for failure in /home/mojo/.pip/pip.log
Anyone have a resolution tip not available on the Seaborn github site?

I think the easiest way is to use sudo:
sudo pip install seaborn
It requires sudo permission to write to usr/local/lib.
Note: If you're using anaconda you won't need sudo to install via pip, once you've conda installed pip, though seaborn may also be available via conda.

Personal installation is a good habit to get into:
pip install --user seaborn
However, there is an even easier way: as of writing python XY maintains up-to-date builds of pandas and seaborn (among other useful packages), so all you have to do is
sudo add-apt-repository ppa:pythonxy/pythonxy-devel
sudo apt-get update
sudo apt-get install python-seaborn python-pandas
Note that this will only work with python 2.x; you will still need pip3 to install the python 3.x packages.

Related

Can't get pip install to work on EMR cluster

I have an EMR (emr-5.30.0) cluster I'm trying to start with a bootstrap file in S3. The contents of the bootstrap file are:
#!/bin/bash
sudo pip3 install --user \
matplotlib \
pandas \
pyarrow \
pyspark
And the error in my stderr file is:
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Command "python setup.py egg_info" failed with error code 1 in /mnt/tmp/pip-build-br9bn1h3/pyspark/
Seems pretty simple...no idea what is going on. Any help is appreciated.
EDIT:
Tried #Dennis Traub suggestion and get same error. New EMR bootstrap looks like this:
#!/bin/bash
sudo pip3 install --upgrade setuptools
sudo pip3 install --user matplotlib pandas pyarrow pyspark
#!/bin/bash
sudo python3 -m pip install matplotlib pandas pyarrow
DO NOT install pyspark. It should be already there in EMR with required config. Installing may cause problems.
You might have an outdated version of setuptools. Try the following script:
#!/bin/bash
sudo pip3 install --upgrade setuptools
sudo pip3 install --user matplotlib pandas pyarrow pyspark

Cannot install tensorflow on raspberry pi 3b+

I am running into an error when I try to install tensorflow using pip on my raspberry pi 3b+.
Here is the error message:
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-p4UFOu/h5py/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-ofsmSC/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-p4UFOu/h5py/
Here is the command I tried that gave the error I mentioned:
sudo pip install tensorflow
I am running the latest version of Raspbian OS and have updated and upgraded my raspberry pi. I am also using python 2.7 and this works successfully with python 2.7 on my ubuntu 18.10 laptop.
Any ideas how I can successfully do this?
Guessing by /tmp/pip-install-p4UFOu/h5py/setup.py, you have the issues with installing the h5py package which is required by tensorflow. Since you are building h5py from source (the prebuilt ARM wheels exist for Python 3.4/3.5 only atm), refer to the h5py installation docs:
To install h5py from source, you need three things installed:
A supported Python version with development headers
HDF5 1.8.4 or newer with development headers
A C compiler
On Raspbian and Python 2, this translates to:
apt install python-dev
apt install libhdf5-dev
apt install gcc (or, if you want the whole development tools to be installed at once, apt install build-essential)
Now pip install h5py should have everything to build and install the package properly.

Problems installing Pillow/PIL in virtual environment without sudo

I have a program that I can run from terminal (no virtual environment) where I install packages with the --user option. Now I want to organize the program in a proper way in Python 2.7 using requirements.txt, setup.py, etc.
To do this I created a virtual environment and I am installing all the necessary packages, so that I can do a "pip freeze > requirements.txt".
Unfortunately I cannot install PIL/Pillow. I used to get a problem with jpeg but I fixed that with "sudo apt-get install libjpeg-dev". Now with these:
pip install Pillow
pip install Pillow --allow-external Pillow --allow-unverified Pillow
I get a permission denied:
...
error: could not create '/home/kinkyboy/virtualenv/tantrix/lib/python2.7/site-packages/PIL': Permission denied
----------------------------------------
Cleaning up...
Command /home/kinkyboy/virtualenv/tantrix/bin/python -c "import setuptools, tokenize;__file__='/home/kinkyboy/virtualenv/tantrix/build/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-S9cPV3-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kinkyboy/virtualenv/tantrix/include/site/python2.7 failed with error code 1 in /home/kinkyboy/virtualenv/tantrix/build/Pillow
Storing debug log for failure in /home/kinkyboy/.pip/pip.log
If I use sudo it works and with --user it doesn't, but obviously these commands do not install in the virtual environment.
Am I missing something?
The solution was to chown the path to the virtual environment. Make sure both ~/.cache/pip and the path to the virtual environment are both owned by the user. In my case the second was not
sudo chown -R your_username:your_username path/to/virtuaelenv/
See #Vingtoft here:
StackOverflow 19471972

Why doesn't xlwings install correctly on Mac OS 10.7.5?

Here's most of the error message. (Here are some more word just to see if a can get Stack Overflow the accept my question.)
bash-3.2$ pip install xlwings
Collecting xlwings
Using cached xlwings-0.3.5.tar.gz
Installing collected packages: psutil, appscript, xlwings
Found existing installation: psutil 0.4.1
DEPRECATION: Uninstalling a distutils installed project (psutil) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Not uninstalling psutil at /Applications/Canopy.app/appdata/canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages, outside environment /Users/schulist/Library/Enthought/Canopy_64bit/User
Running setup.py install for psutil
Complete output from command psutil/_psutil_osx.c:1635: error: expected ‘)’ before ‘CFDictionaryGetValue’
error: command 'gcc' failed with exit status 1
----------------------------------------
Can't roll back psutil; was not uninstalled
Command "/Users/schulist/Library/Enthought/Canopy_64bit/User/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/yr/zbxgljhx6lxb0hwn66w4t3jw0000gp/T/pip-build-a4Q7fB/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/yr/zbxgljhx6lxb0hwn66w4t3jw0000gp/T/pip-JDRpLz-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/schulist/Library/Enthought/Canopy_64bit/User/include/site/python2.7/psutil" failed with error code 1 in /private/var/folders/yr/zbxgljhx6lxb0hwn66w4t3jw0000gp/T/pip-build-a4Q7fB/psutil
You have an issue there with upgrading psutil, a dependency of xlwings on Mac. Since you seem to be using Canopy, you should be able to install xlwings usings their own packages and it should properly take care of the dependencies.
Other than that, just upgrading psutil first should probably enable you to install xlwings via pip again.

"error: command 'x86_64-linux-gnu-gcc' failed with exit status 1" in virtualenv

Environment: Linux Mint 17 Cinnamon.
This error is displayed:
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
when attempting the following in a virtualenv:
pip install lxml
pip install pillow
pip install pycrypto
pip install pymongo (fails but still shows in pip freeze)
There are several solutions here that recommend installing python2.7-dev:
Installing Pillow error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Installing lxml in virtualenv via pip install error: command 'x86_64-linux-gnu-gcc' failed
Pillow installation error: command 'gcc' failed with exit status 1
fatal error: Python.h: No such file or directory
I am confused by this recommendation however because it is my understanding that using something like:
sudo apt-get install python2.7-dev
would add this to the main *system* instance of Python, rather that the one in virtualenv. (see - https://unix.stackexchange.com/a/56392/92486)
Can I add python2.7-dev just to the virtualenv version of Python?
Most of the time these are dependency-issues.
Following the stack-trace of the gcc compiler one can see the missing files. Sometimes installing the Python development packages is not enough.
For example:
I tried to do pip install requests[security] in my virtualenv foo. This is the result that the pip-installer gave me.
Failed building wheel for cryptography
Running setup.py bdist_wheel for cffi
Stored in directory: /root/.cache/pip/wheels/99/e7/9a/68b1c8ca6f6f92b5feebd4d9434f50712b84f6a66d1285ea21
Successfully built cffi
Failed to build cryptography
Installing collected packages: cffi, cryptography, pyOpenSSL, ndg-httpsclient, requests
Running setup.py install for cryptography
Complete output from command /opt/foo/django-cms-virtualenv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-eZaLAG/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BwgYTp-record/install-record.txt --single-version-externally-managed --compile --install-headers /opt/foo/django-cms-virtualenv/include/site/python2.7/cryptography:
running install
running build
running build_py
running egg_info
writing requirements to src/cryptography.egg-info/requires.txt
writing src/cryptography.egg-info/PKG-INFO
writing top-level names to src/cryptography.egg-info/top_level.txt
writing dependency_links to src/cryptography.egg-info/dependency_links.txt
writing entry points to src/cryptography.egg-info/entry_points.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
warning: no previously-included files matching '*' found under directory 'vectors'
writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
running build_ext
building '_Cryptography_cffi_a269d620xd5c405b7' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.c -o build/temp.linux-x86_64-2.7/src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.o
src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.c:217:25: fatal error: openssl/aes.h: Datei oder Verzeichnis nicht gefunden
#include <openssl/aes.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
The important part is the: #include <openssl/aes.h>
The compiler makes pretty clear that it is demanding this file - but it is not there in the filesystem.
Knowing that, the only thing left to do is: install the needed libraries!
Find out which package is needed for your distribution:
e.g. for Ubuntu you can go to The Ubuntu Package Search Site and enter the missing file you are looking for. In this case "aes.h"
Install the needed packages using your distributions package management tool:
e.g. for Ubuntu:
aptitude install libssl-dev
Retry with pip in your virtualenv:
pip install requests[security]
I installed python2.7-dev via Synaptic Package Manager in Linux Mint 17.
I could then accomplish the following in virtualenv:
pip install pillow
pip install pycrypto
And then I installed libxml2-dev and libxslt1-dev via Synaptic and could accomplish the following:
pip install lxml
I also did this so that the pymongo install didn't have any errors:
pip uninstall pymongo
pip install pymongo # i defined the version i needed ie pip install pymongo==2.6.2
I'm still confused how this fixes the problem, because I thought virtualenv was an isolated environment. Any clarification about this appreciated.
Work for me :
Just install python2.7-dev first
sudo apt-get install python2.7-dev
In Ubuntu 16.04.1 this worked for me:
sudo apt-get install libxml2-dev libxslt1-dev python-dev
For me the installation of lxml was failing on compilation. I followed the instructions for installation of lxml and reduced the compiler optimizations:
sudo CFLAGS="-O0" pip install lxml
After doing this, the compile of lxml succeeded.
This can be a problem in the pip. To solve, try:
sudo apt-get remove python-pip
To install pip, securely download get-pip.py.
https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
The cffi library needs libffi-dev:
sudo apt-get install libffi libffi-dev
Easiest way is:
sudo apt-get build-dep python-imaging
and then
pip install pillow
This works for me, 12.04, python2.7.6 for package lxml
sudo pip install libxml2 libxml2-dev libxslt1-dev
sudo pip install lxml