I'm trying to install h5py package via pip for python 2.7, I can't use sudo and I have python 3.2 installed too.
Here is my attemp:
I have installed pip:
curl -O https://bootstrap.pypa.io/get-pip.py
python2.7 get-pip.py --user
then I installed wheel
~/.local/bin/pip2.7 install --user wheel
Collecting wheel
/home/myuser/.local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/home/myuser/.local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: wheel
Successfully installed wheel-0.29.0
Then installed h5py, seems it failed.
~/.local/bin/pip2.7 install --user h5py
Collecting h5py
Using cached h5py-2.5.0.tar.gz
/usr/lib/python2.7/dist-packages/setuptools/command/install_scripts.py:3: UserWarning: Module pip was already imported from /home/myuser/.local/lib/python2.7/site-packages/pip/__init__.pyc, but /usr/lib/python2.7/dist-packages is being added to sys.path
from pkg_resources import Distribution, PathMetadata, ensure_directory
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in /usr/lib/python2.7/dist-packages (from h5py)
Requirement already satisfied (use --upgrade to upgrade): Cython>=0.17 in /home/myuser/.local/lib/python2.7/site-packages (from h5py)
Requirement already satisfied (use --upgrade to upgrade): six in /home/myuser/.local/lib/python2.7/site-packages (from h5py)
Building wheels for collected packages: h5py
Running setup.py bdist_wheel for h5py ... error
Complete output from command /usr/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-7KTR1Y/h5py/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpE1KVSupip-wheel- --python-tag cp27:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
Failed building wheel for h5py
Running setup.py clean for h5py
Failed to build h5py
Installing collected packages: h5py
Running setup.py install for h5py ... done
Successfully installed h5py-2.5.0
run python via python2.7
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import h5py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myuser/.local/lib/python2.7/site-packages/h5py/__init__.py", line 23, in <module>
from . import _conv
File "h5py/h5r.pxd", line 21, in init h5py._conv (/tmp/pip-build-7KTR1Y/h5py/h5py/_conv.c:7356)
File "h5py/_objects.pxd", line 12, in init h5py.h5r (/tmp/pip-build-7KTR1Y/h5py/h5py/h5r.c:2941)
File "h5py/_objects.pyx", line 1, in init h5py._objects (/tmp/pip-build-7KTR1Y/h5py/h5py/_objects.c:7226)
ImportError: /home/myuser/.local/lib/python2.7/site-packages/h5py/defs.so: undefined symbol: H5Oexists_by_name
What I'm doing wrong?
Update:
~/.local/bin/pip2.7 show h5py
---
Metadata-Version: 1.1
Name: h5py
Version: 2.5.0
Summary: Read and write HDF5 files from Python
Home-page: http://www.h5py.org
Author: Andrew Collette
Author-email: andrew dot collette at gmail dot com
License: UNKNOWN
Location: /home/myuser/.local/lib/python2.7/site-packages
Requires: numpy, Cython, six
My OS is Ubuntu 12.04.1 LTS.
So there's a few things happening here:
Missing SSL certificate problems (see the urllib3 link)
setuptools not finding wheel, meaning a wheel isn't built, so pip calls python setup.py install directly
h5py is trying to use a function in HDF5 which does not exist in the version of HDF5 that's on your system.
1 and 2 are worth fixing (as they may be symptoms of other problems with the system), but 3 is the reason h5py isn't working for you.
h5py is trying to access H5Oexists_by_name. According to https://www.hdfgroup.org/HDF5/doc/RM/RM_H5O.html#Object-ExistsByName, this first appeared in version 1.8.5 of HDF5. According to http://packages.ubuntu.com/source/precise/hdf5, the version of HDF5 on your system is 1.8.4 (but you need to check this!). Somehow h5py thinks the HDF5 library on you system is 1.8.5 or higher (see https://github.com/h5py/h5py/blob/4ee8f89b6dc658fdea5dc62d0f29058121928cfe/h5py/h5o.pyx#L172)
It looks like someone else has run into a similar problem, and filed https://bugs.launchpad.net/ubuntu/+source/hdf5/+bug/1418220. You probably want to inform them of your problem, so that they can produce a bug fix.
Related
This is what I get every time I want to install any package via apt and make && make install:
Setting up pgadmin4-apache2 (4.23-1.pgdg18.04+1) ...
Traceback (most recent call last):
File "setup.py", line 18, in <module>
from pgadmin.model import db, User, Version, ServerGroup, Server, \
File "/usr/share/pgadmin4/web/pgadmin/__init__.py", line 19, in <module>
from flask import Flask, abort, request, current_app, session, url_for
ModuleNotFoundError: No module named 'flask'
dpkg: error processing package pgadmin4-apache2 (--configure):
installed pgadmin4-apache2 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
pgadmin4-apache2
E: Sub-process /usr/bin/dpkg returned an error code (1)
I have flask installed:
$ which flask
/home/anna/.local/bin/flask
$ whereis flask
flask: /usr/bin/flask /usr/local/bin/flask /home/anna/.local/bin/flask
$ python -m flask --version
Python 2.7.17
Flask 1.1.2
Werkzeug 1.0.1
but:
$ python3 -m flask --version
/usr/local/bin/python3: No module named flask
tried to install flask by both pip and pip3:
$ pip3 install flask
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: flask in /home/anna/.local/lib/python3.6/site-packages (1.1.2)
Requirement already satisfied: click>=5.1 in /home/anna/.local/lib/python3.6/site-packages (from flask) (7.1.2)
Requirement already satisfied: itsdangerous>=0.24 in /home/anna/.local/lib/python3.6/site-packages (from flask) (1.1.0)
Requirement already satisfied: Jinja2>=2.10.1 in /home/anna/.local/lib/python3.6/site-packages (from flask) (2.11.2)
Requirement already satisfied: Werkzeug>=0.15 in /home/anna/.local/lib/python3.6/site-packages (from flask) (1.0.1)
Requirement already satisfied: MarkupSafe>=0.23 in /home/anna/.local/lib/python3.6/site-packages (from Jinja2>=2.10.1->flask) (1.1.1)
What can I do to fix that?
UPD: I removed pgadmin4-apache2 and it worked!
try this :
sudo pip3 install flask
or
python3 -m pip install flask
as you are getting site-package is not writeable, with sudo you are super user
You can also work in python3 environment and install packages there only.
As #Bramhesh mentioned using apt is the wrong way to go.
Normally you should use:
pip3 install flask
To check your already installed modules use:
pip3 freeze
Sometimes you run into errors during installation e.g. when you don't have write rights in the direction your python environment is saved.
Then use:
sudo pip3 install flask
But as it seems you already have a flask module installed. You can upgrade this by using:
pip3 install flask --upgrade
Cheers!
In order to install the Python module hidapi: I installed python 2.7 with home-brew:
brew install python2
I think it installed 2.7.15. Python information:
Users-MacBook-Air:~ user$ python -V
Python 2.7.10
Users-MacBook-Air:~ user$ which python
/usr/bin/python
I believe 2.7.10 was already installed (Apple OEM?).
The OS X command:
pip install hidapi
Indicates:
Requirement already satisfied: hidapi in
/usr/local/lib/python2.7/site-packages (0.7.99.post21) Requirement
already satisfied: setuptools>=19.0 in
/usr/local/lib/python2.7/site-packages (from hidapi) (39.1.0)
Attempts to import HID from the Python command line results in error:
>>> import hid
Traceback (most recent call last): File "", line 1, in
ImportError: No module named hid
There may be more than one version of 2.7 installed (2.7.15?).
How can I test if a newer (second Python instance of 2.7.X) was installed today?
How can I invoke Python 2.7.15 if was installed today?
How can 2.7.10 be granted visibility to the hid module?
It I can invoke Python 2.7.15 and try to import the hid module, that should inch the troubleshooting process along.
UPDATE
Users-MacBook-Air:~ user$ python2
Python 2.7.15 (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
>>>
ONLY 2.7.15 has 'hid' visibility: the other two versions return an error.
Users-MacBook-Air:~ user$ python -V
Python 2.7.10
Users-MacBook-Air:~ user$ python2 -V
Python 2.7.15
Users-MacBook-Air:~ user$ python2.7 -V
Python 2.7.10
All pip references lead to the same place:
Users-MacBook-Air:~ user$ pip -V
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
Users-MacBook-Air:~ user$ pip2 -V
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
Users-MacBook-Air:~ user$ pip2.7 -V
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
I think you've figured out the other questions, but
How can 2.7.10 be granted visibility to the hid module
You would need to install it using pip via easy_install however adding libraries into your system Python is usually frowned upon, which is why virtualenv's exist, but, you would need to install that module as well
Besides that, Python3 should generally be used for any new Python development
Goal: Have python 2.7.14 and python 3.6 on my RHEL server and use pip2/pip3 to manage both.
Note: Although this server lacks an internet connection, I can download them separately and upload them to this server.
I recently installed RHEL 7.2 on a VM, this installs python 2.7.5 by default.
I decided upgrade this by doing a parallel install of 2.7.14 (using make altinstall method and keeping the existing 2.7.5 intact). Also installed python 3.6 as I plan to port all my existing python code to it in the future.
The problem arises when I try to install pip for the Python 2.7.14 or any libraries (as you will see in a little bit).
I first did a easy_install of pip:
[root#VMW01 bin]# easy_install pip
Searching for pip
Best match: pip 9.0.1
Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip3 script to /usr/local/bin
Installing pip3.5 script to /usr/local/bin
Using /usr/local/lib/python3.6/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
This installs pip for python 2.7.5 and 3.6 but not for python 2.7.14.
Next, I downloaded the get-pip.py:
This gets installed fine for python 2.7.5 but not for python 2.7.14:
[root#VMW01 pshah]# python get-pip.py
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 978kB/s
Collecting wheel
Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
100% |████████████████████████████████| 51kB 9.2MB/s
Installing collected packages: pip, wheel
Successfully installed pip-9.0.1 wheel-0.30.0
[root#VMW01 pshah]# /usr/local/bin/python2.7 get-pip.py
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
This seems like a lack of a SSL libray.
First, I did install this using yum:
[root#VMW01 pshah]# yum install openssl
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package 1:openssl-1.0.1e-42.el7_1.9.x86_64 already installed and latest version
Nothing to do
[root#VMW01 pshah]# yum install openssl-devel
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package 1:openssl-devel-1.0.1e-42.el7_1.9.x86_64 already installed and latest version
Nothing to do
Second, this seems to be present for python 2.7.5
[root#VMW01 pshah]# python
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
Am I overarching too much? Should I settle with the default installation of 2.7.5 and python 3.6?
I know virtualenv might be a solution here, but i'm not sure how I can make it work with Apache executing python scripts.
Thanks.
As it mentions here: https://pip.pypa.io/en/latest/installing I did a local install of pip but called the python executable for python 2.7.14.
Downloaded the .whl files for wheel, setuptools and pip and then ran the below:
[root#VMW01 pshah]# /usr/local/bin/python2.7 get-pip.py --no-index --find-link=.
Collecting pip
Collecting setuptools
Collecting wheel
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-36.5.0 wheel-0.30.0
I believe calling pip2.7 will install packages for the python 2.7.14 now.
Tested this by installing the xlrd library (Note - I had the xlrd tarball in the local directory):
[root#VMW01 pshah]# pip2.7 install xlrd-1.1.0.tar.gz
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Processing ./xlrd-1.1.0.tar.gz
Building wheels for collected packages: xlrd
Running setup.py bdist_wheel for xlrd ... done
Stored in directory: /root/.cache/pip/wheels/b9/dc/43/e6acfa12bc48cdf3654dd7f44c66880548ea0322324bc6095f
Successfully built xlrd
Installing collected packages: xlrd
Successfully installed xlrd-1.1.0
[root#VMW01 pshah]# /usr/local/bin/python2.7
Python 2.7.14 (default, Oct 6 2017, 18:31:52)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xlrd
>>>
I have installed eventlet library in python using : pip install eventlet. But when I tried to import eventlet this error occured:
$python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import eventlet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named eventlet
I tried to install it again but I got this :
$pip install eventlet
Requirement already satisfied (use --upgrade to upgrade): eventlet in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/eventlet-0.18.1-py3.5.egg
Requirement already satisfied (use --upgrade to upgrade): greenlet>=0.3 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/greenlet-0.4.9-py3.5-macosx-10.6-intel.egg (from eventlet)
How to rectify this error?
P.S : I am using Python 2.7
This question is not specific to Eventlet, it's just about managing multiple versions of Python on OSX.
Your pip command installed eventlet into /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5, see version.
It means you actually have two Python versions installed: 2.7 and 3.5 and pip works with 3.5.
Your options:
(recommended) use separate virtualenv [1] for every project, explicitly specify python version when creating virtualenv using virtualenv --python=python2.7 /path/to/new/venv
run python3 and use eventlet in latest Python
run pip2 install eventlet
symlink pip to pip2 ln -snf $(which pip2) $(which pip)
[1] http://docs.python-guide.org/en/latest/dev/virtualenvs/
You may also use
$py -2 -m pip install eventlet
It worked for me in Windows 10.
$pip install eventlet
This worked for me in windows10
I have a Redhat 6 box which originally had python 2.6 installed on it (invoked by /usr/bin/python). A few days ago I installed 2.7.10 (invoked by /usr/local/bin/python or simply python).
Earlier today I installed pip using sudo easy_install pip. The result of whereis pip is pip: /usr/bin/pip2.6 /usr/bin/pip
Then I wanted to install the pandas package by running sudo pip install pandas. It reported success but import pandas produces an error for both versions of python:
myPrompt 733] python
Python 2.7.10 (default, Jul 16 2015, 14:41:11)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
>>> exit()
myPrompt 734] /usr/bin/python
Python 2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
>>> exit()
myPrompt 735] pip install pandas
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==7.1.0
myPrompt 736] sudo pip install pandas
Enter PASSCODE:
Requirement already satisfied (use --upgrade to upgrade): pandas in /usr/lib64/python2.6/site-packages
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/lib/python2.6/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): pytz>=2011k in /usr/lib/python2.6/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.0 in /usr/lib64/python2.6/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /usr/lib/python2.6/site-packages (from python-dateutil->pandas)
So there is some sort of confusion with pip configuration and how packages get installed. How can I untangle this? Do I need to reinstall pip?
Ultimately, I don't care about python 2.6 and only want to work with 2.7
Thx
Looks like the reason was that I installed the packages as root. Doing
sudo chmod -R ugo+rX /usr/local/lib/python2.7/site-packages
fixed the problem
For reference, this can happen when you have multiple Python installations, for example via brew. In that case remove one:
brew remove python --force
This one fixed for me.
This case can be fixed using the steps provided in the following answer: Easy_install and pip broke: pkg_resources.DistributionNotFound: distribute==0.6.36
It simply replaces the current pip install (which refers to the new/wrong python environment) with a fresh/correct one.