I am trying to install ruamel.yaml python library in a Centos 7 machine where I don't have internet connection. I tried this:
installed libyaml-devel, python-devel, python-pip using a local repository
downloaded ruamel.yaml-0.13.14.tar & ruamel.ordereddict-0.4.6.tar(dependency) from pypi.
now I am able to install ruamel.ordereddict using pip install .,
but when I tried to install ruamel.yaml in the same way, I got the following exception:
[root#limulus ruamel.yaml-0.13.14]# pip install .
Processing /tmp/python/ruamel.yaml-0.13.14
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/usr/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 7, in <module>
from setuptools.command.install import install
File "/usr/lib/python2.7/site-packages/setuptools/command/__init__.py", line 8, in <module>
from setuptools.command import install_scripts
File "/usr/lib/python2.7/site-packages/setuptools/command/install_scripts.py", line 3, in <module>
from pkg_resources import Distribution, PathMetadata, ensure_directory
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 74, in <module>
import parser
File "parser.py", line 77, in <module>
from ruamel.yaml.error import MarkedYAMLError # type: ignore
File "/usr/lib64/python2.7/site-packages/ruamel/__init__.py", line 5, in <module>
__import__('pkg_resources').declare_namespace(__name__)
AttributeError: 'module' object has no attribute 'declare_namespace'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-oOWX1x-build/
What is the correct way of installing a python library in offline mode?
It looks like you have been expanding the tar files, which is not necessary, but I am not sure if that is the reason why you get this error, you probably are also missing the typing dependency.
What you shouldn't do is use the system installed pip, it is almost out of date and on some systems actually causes problems because of unfixed bugs in those old versions.
What you also should not do is install packages using pip outside of a Python virtualenv, as this might break your system when it updates/overwrites things in the systems site-packages/dist-packages directory. The solution provided below only installs pip/wheels/virtualenv in the system directory, that is AFAIK safe, but there are ways around that as well if it would necessary.
You should also consider using the provided wheels to install packages. That way C extension don't need compilation.
On a machine that is online do:
mkdir /tmp/offline
cd /tmp/offline
# your python-pip installed pip might not support wheels
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
wget https://pypi.python.org/packages/a7/37/947b4329c4a3c72093b6c8e9b4be8c7f10c32dbb78848d3a234ce01c059d/wheel-0.30.0a0.tar.gz
wget https://pypi.python.org/packages/6f/86/3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/virtualenv-15.1.0-py2.py3-none-any.whl
Now download the required wheels (.tar.gz if not available):
wget https://pypi.python.org/packages/96/4b/5251bf469f37e49e0c92f841b5b3ef01a1c9d652cc018df470e5ae235eb8/ruamel.ordereddict-0.4.9-cp27-cp27mu-manylinux1_x86_64.whl
wget https://pypi.python.org/packages/63/40/c38b857ec6a083e534ee9a9f655741120d4bfd9139232681f976cf44272b/ruamel.yaml-0.13.14-cp27-cp27mu-manylinux1_x86_64.whl
wget https://pypi.python.org/packages/b6/0c/53c42edca789378b8c05a5496e689f44e5dd82bc6861d1ae5a926ee51b84/typing-3.5.3.0.tar.gz
Copy the six files to a new directory your offline system, and there do
sudo pip install pip*.tar.gz wheel*.tar.gz
sudo pip install virtualenv*
virtualenv ~/ruamel
source ~/ruamel/bin/activate
pip install typing* ruamel*
That gives you a virtualenv with ruamel.yaml installed, just add your application in there as well.
The downloads used here are current as of 2017-01-07, you can get more up-to-date ones using your browser (on the on-line system) if necessary.
Related
This probably falls under "don't do this" category, given https://github.com/agronholm/pythonfutures/issues/41 - it's a backport library specifically intended for use only on Python 2. But strangely, I'm seeing having it installed cause symptoms that are especially bad on Amazon Linux and not as noticeable elsewhere. Test case:
$ docker run -it amazonlinux /bin/bash
bash-4.2# yum install -y python36-virtualenv > /dev/null
bash-4.2# virtualenv-3.6 ~/testenv
Using base prefix '/usr'
New python executable in /root/testenv/bin/python3.6
Also creating executable in /root/testenv/bin/python
Installing setuptools, pip, wheel...done.
bash-4.2# source ~/testenv/bin/activate
(testenv) bash-4.2# pip --version
pip 9.0.3 from /root/testenv/local/lib/python3.6/site-packages (python 3.6)
(testenv) bash-4.2# pip install futures
Collecting futures
Downloading futures-3.1.1.tar.gz
Building wheels for collected packages: futures
Running setup.py bdist_wheel for futures ... done
Stored in directory: /root/.cache/pip/wheels/ad/79/48/b32521764d59b16fd1bc0ffd
5862f6d3bf770c7d73ea1fb12a
Successfully built futures
Installing collected packages: futures
Successfully installed futures-3.1.1
(testenv) bash-4.2# pip --version
Traceback (most recent call last):
File "/root/testenv/bin/pip", line 7, in <module>
from pip import main
File "/root/testenv/local/lib/python3.6/site-packages/pip/__init__.py", line 4
5, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/root/testenv/local/lib/python3.6/site-packages/pip/vcs/subversion.py",
line 9, in <module>
from pip.index import Link
File "/root/testenv/local/lib/python3.6/site-packages/pip/index.py", line 31,
in <module>
from pip.wheel import Wheel, wheel_ext
File "/root/testenv/local/lib/python3.6/site-packages/pip/wheel.py", line 6, i
n <module>
import compileall
File "/usr/lib64/python3.6/compileall.py", line 20, in <module>
from concurrent.futures import ProcessPoolExecutor
File "/root/testenv/local/lib/python3.6/site-packages/concurrent/futures/__ini
t__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/root/testenv/local/lib/python3.6/site-packages/concurrent/futures/_base
.py", line 381
raise exception_type, self._exception, self._traceback
^
SyntaxError: invalid syntax
Simply having the futures package installed on python 3 on other Linux distributions doesn't seem to cause pip to break, I haven't been able to cause the same symptom on Ubuntu or Fedora yet. What is going on inside a virtualenv on amazonlinux that causes this issue to be especially bad? If I install virtualenv via pip rather than from the amazon linux yum package python36-virtualenv, the problem doesn't manifest there either.
Whenever I am running any command using pip, I am getting the following error. I have tried uninstalling python,pip and reinstalling them back again. I also used
sudo apt-get autoremove
and then updated and upgraded
sudo apt-get update
sudo apt-get upgrade
And once again installed python and pip. I am still getting the same error whenever I run any command using pip.
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/home/shashank/.local/lib/python2.7/site-packages/pip/__init__.py", line 28, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/home/shashank/.local/lib/python2.7/site-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/home/shashank/.local/lib/python2.7/site-packages/pip/download.py", line 34, in <module>
from pip.utils.logging import indent_log
ImportError: No module named logging
Can anybody suggest a solution?
Edit
I have read the question which is used to flag my question as a duplicate.
I am not using a virtual environment and I have already tried the answer given over there. Moreover I am encountering a problem when I run pip in my terminal
The output of the command
locate logging
/etc/java-9-openjdk/logging.properties
/home/shashank/.local/share/Trash/files/logging.py
/home/shashank/.local/share/Trash/files/logging.pyc
/home/shashank/.local/share/Trash/info/logging.py.trashinfo
/home/shashank/.local/share/Trash/info/logging.pyc.trashinfo
/lib/lsb/init-functions.d/50-ubuntu-logging
/usr/lib/jvm/java-9-openjdk-amd64/jmods/java.logging.jmod
/usr/lib/jvm/java-9-openjdk-amd64/lib/logging.properties
/usr/lib/pm-utils/sleep.d/00logging
/usr/lib/python2.7/logging
/usr/lib/python2.7/dist-packages/pip/utils/logging.py
/usr/lib/python2.7/dist-packages/pip/utils/logging.pyc
/usr/lib/python2.7/logging/__init__.py
/usr/lib/python2.7/logging/__init__.pyc
/usr/lib/python2.7/logging/config.py
/usr/lib/python2.7/logging/config.pyc
/usr/lib/python2.7/logging/handlers.py
/usr/lib/python2.7/logging/handlers.pyc
/usr/lib/python3/dist-packages/UnityTweakTool/config/logging.py
/usr/lib/python3/dist packages/UnityTweakTool/config/__pycache__/logging.cpython-35.pyc
/usr/lib/python3/dist-packages/plainbox/impl/logging.py
/usr/lib/python3/dist-packages/plainbox/impl/__pycache__/logging.cpython-35.pyc
/usr/lib/python3.5/logging
/usr/lib/python3.5/logging/__init__.py
/usr/lib/python3.5/logging/__pycache__
/usr/lib/python3.5/logging/config.py
/usr/lib/python3.5/logging/handlers.py
/usr/lib/python3.5/logging/__pycache__/__init__.cpython-35.pyc
/usr/lib/python3.5/logging/__pycache__/config.cpython-35.pyc
/usr/lib/python3.5/logging/__pycache__/handlers.cpython-35.pyc
/usr/share/icons/hicolor/16x16/categories/applications-microblogging-panel.png
/usr/share/icons/ubuntu-mono-dark/categories/22/applications-microblogging-panel.svg
/usr/share/icons/ubuntu-mono-dark/categories/24/applications-microblogging-panel.svg
/usr/share/icons/ubuntu-mono-light/categories/22/applications-microblogging-panel.svg
/usr/share/icons/ubuntu-mono-light/categories/24/applications-microblogging-panel.svg
/usr/src/linux-headers-4.4.0-59-generic/include/config/fusion/logging.h
/usr/src/linux-headers-4.4.0-59-generic/include/config/scsi/logging.h
/usr/src/linux-headers-4.4.0-59-generic/include/config/sfc/mcdi/logging.h
/usr/src/linux-headers-4.4.0-62-generic/include/config/fusion/logging.h
/usr/src/linux-headers-4.4.0-62-generic/include/config/scsi/logging.h
/usr/src/linux-headers-4.4.0-62-generic/include/config/sfc/mcdi/logging.h
It's obvious from your traceback that you have a version of pip installed in your home directory, at /home/shashank/.local/lib/python2.7/site-packages/pip/. Delete that. If you aren't certain what else is contained there, better delete all /home/shashank/.local/lib/python2.7. After you delete it, it will use the system's default pip that you installed with apt.
I have to use python-elasticsearch library on a machine where I could only execute programs. I am trying to use elasticsearch module by appending sys.path as mentioned below. I am facing below issue. It looks like the problem related to what is mentioned here
https://github.com/elastic/elasticsearch-py/issues/253 . But how do I resolve this when I dont have sudo access or any sort of upgrade access.
**Note :**I don't have sudo access on this machine so I cannot have venv, pip etc.
import sys
sys.path.append('/tmp/elasticpy/elasticsearch-2.3.0')
from elasticsearch import Elasticsearch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/__init__.py", line 17, in <module>
from .client import Elasticsearch
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/client/__init__.py", line 5, in <module>
from ..transport import Transport
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/transport.py", line 4, in <module>
from .connection import Urllib3HttpConnection
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/connection/__init__.py", line 3, in <module>
from .http_urllib3 import Urllib3HttpConnection
File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/connection/http_urllib3.py", line 2, in <module>
import urllib3
ImportError: No module named urllib3
#nehal Thanks for your suggestion I was able to get it fixed. Please find the
series of steps I used to install
Used easy_install to install package pip
Appended PYTHONPATH
used pip to install virtualenv
Activated new virtualenv
Installed elasticsearch using pip
export PYTHONPATH="${PYTHONPATH}:/tmp/pytest/"
easy_install --install-dir /tmp/pytest/ pip
pip install virtualenv --prefix /tmp/pytest/
export PATH="${PATH}:/tmp/pytest:/tmp/pytest/bin"
export PYTHONPATH="${PYTHONPATH}:/tmp/pytest/lib/python2.7/site-packages"
cd /tmp/
virtualenv venv
source venv/bin/activate
pip install elasticsearch
I'm getting this error when I try to install pip2.7.
I have python 2.7 as my default already, but I'm not sure why I'm getting this.
OS: CentOS 6.5
OpenSSL has been installed already.
I followed this guide to install Python 2.7:
http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
[root#myservername arandomfolder]# python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 17474, in <module>
main()
File "get-pip.py", line 17466, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 17406, in bootstrap
import pip
File "/tmp/tmpXq2wUP/pip.zip/pip/__init__.py", line 10, in <module>
File "/tmp/tmpXq2wUP/pip.zip/pip/util.py", line 18, in <module>
File "/tmp/tmpXq2wUP/pip.zip/pip/_vendor/distlib/version.py", line 14, in <module>
File "/tmp/tmpXq2wUP/pip.zip/pip/_vendor/distlib/compat.py", line 31, in <module>
ImportError: cannot import name HTTPSHandler
You have a Python without SSL support compiled. Unfortunately, get-pip appears to require SSL support.
If you are using a Linux distribution, make sure OpenSSL is installed, including the headers when compiling Python from source.
So looks like i was missing the openssl-devel dependency
after I had installed that, i was able to install this.
I was having this issue on a Centos 6.5 machine even though I had openssl and openssl-devel installed. I was also using the steps from the site:
http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
I removed python packages I had installed before: virtualenv, NetworkX, and pil:
pip uninstall virtualenv
pip uninstall NetworkX
pip uninstall pil
Then I compiled Python 2.7 again and no longer had this issue. After I followed the steps in the link below, I reinstalled the above packages using pip2.7:
pip2.7 install virtualenv
pip2.7 install NetworkX
pip2.7 install pil --allow-external pil --allow-unverified pil
I have meet the same problem. I solved it by install openssl-devel and reconfigure, make, make install python3:
yum install openssl-devel
then go to the python3 directory:
./configure --with-zlib --with-openssl
make
make install
I'm completely new to programming. I've been trying various ways to install NLTK on my Mac (running OS 10.5.8), and none of them is working. Please help! Here's what I've done so far.
Since at first I didn't realize that newer versions of Python required OS 10.6 or higher, I first tried to install the latest versions of both Python 3 and Python 2, but this obviously didn't work. I then cottoned on and found an older installation (the filename is python-2.7.6-macosx10.3.dmg), which installed successfully.
I then tried to follow the instructions on this page, which I copy below:
Install Setuptools: http://pypi.python.org/pypi/setuptools
Install Pip: run sudo easy_install pip
Install Numpy (optional): run sudo pip install -U numpy
Install PyYAML and NLTK: run sudo pip install -U pyyaml nltk
Test installation: run python then type import nltk
Steps 1 and 2 worked fine, but when I try steps 3 and 4, I get an error. The error is the same whether I try step 3 or step 4:
unknown0021E9E0E476:~ Tom$ sudo pip install -U numpy
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module> load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2173, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1906, in loadentry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/util.py", line 17, in <module>
from pip.vendor.distlib import version
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/vendor/distlib/version.py", line 13, in <module>
from .compat import string_types
File "/Library/Python/2.5/site-packages/pip-1.4.1-py2.5.egg/pip/vendor/distlib/compat.py", line 276
return b''
^
SyntaxError: invalid syntax
I then found a different set of instructions on this page. It first has you install Xcode and MacPorts, which I did (again finding older versions compatible with 10.5.8). I got through the next few steps successfully: installed python27, made it the system default (sudo port select --set python python27), and installed the dependencies py27-numpy, py27-yaml, and py27-scipy. However, I can't install one needed package, py27-matplotlib. Here's what happens when I try:
unknown0021E9E0E476:~ Tom$ sudo port install py27-matplotlib
---> Computing dependencies for py27-matplotlib
---> Dependencies to be installed: py27-pyobjc-cocoa py27-pyobjc py27-six py27-tkinter tk Xft2 tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-tornado py27-backports-ssl_match_hostname py27-backports
---> Staging py27-pyobjc into destroot
Error: org.macports.destroot for port py27-pyobjc returned: command execution failed
Error: Failed to install py27-pyobjc
Please see the log file for port py27-pyobjc for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-pyobjc/py27-pyobjc/main.log
Error: The following dependencies were not installed: py27-pyobjc-cocoa py27-pyobjc py27-six py27-tkinter tk Xft2 tcl xorg-libXScrnSaver xorg-scrnsaverproto py27-tornado py27-backports-ssl_match_hostname py27-backports
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: Processing of port py27-matplotlib failed
Without this package, I can't go on to install NLTK.
I've also tried installing NLTK in PyCharm, but that didn't work either: see this question. I'm at my wits' end here, so any help would be much appreciated!
ETA: Problem solved! I downloaded the tar.gz file from https://pypi.python.org/pypi/nltk and followed the install instructions in the package, and now I can import NLTK in the Python shell. Is it possible that I was simply trying to install things while in the wrong directory? (I'd still like to use NLTK in PyCharm, so answers to that question will still be welcome.)
Try installing the scipy package which includes matplotlib and numpy, I was a TA on a course where we used numpy and matplotlib quite a lot and using the scipy package to install was a solution for a lot of people.
The individual binary and source packages are available from: scipy docs
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose