Determine python version in Easy Install - python

I wan't to install 'twisted' module on CentOS 5.9 . There is python 2.4 by default on it and because of other program dependencies I can't remove python 2.4 .
I have installed Python 2.7 by yum install python27 and installed Easy Install by yum install python-setuptools . Now when I try to install 'twisted' with easy_install twisted I got this error:
< ... truncated ... >
Running Twisted-12.3.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-YeUGBS/Twisted-12.3.0/egg-dist-tmp-NhwZo-
Traceback (most recent call last):
File "/usr/bin/easy_install", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1670, in main
with_ei_usage(lambda:
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1659, in with_ei_usage
return f()
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1674, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib/python2.4/distutils/core.py", line 149, in setup
dist.run_commands()
File "/usr/lib/python2.4/distutils/dist.py", line 946, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.4/distutils/dist.py", line 966, in run_command
cmd_obj.run()
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 211, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 446, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 471, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 655, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 930, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 919, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 26, in run_setup
DirectorySandbox(setup_dir).run(
File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 63, in run
return func()
File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 29, in <lambda>
{'__file__':setup_script, '__name__':'__main__'}
File "setup.py", line 64, in ?
File "setup.py", line 46, in main
File "./twisted/__init__.py", line 47
class Dummy(object):
^
SyntaxError: invalid syntax
As you see, Easy Install use python 2.4 instead of python 2.7 . How can it force it to use python 2.7 ?

You can manually use which ever Python version you want by typing e.g. Python2.7 <script>. Try to execute python2.7 -m easy_install twisted instead.
If for some reason easy_install wasn't installed for Python 2.7 you can download and install it manually here.

Related

python on an AWS m6g instance

I am trying to install a reasonable python 3 on an AWS m6g instance - this is their latest and greatest, and therein lies the rub. It is an ARM64 box, so there is no anaconda install for that (that I know of). I am installing packages manually via pip3, and after much loading of the requisite system packages, compilers, and so on, things mostly work WITH THE EXCEPTION OF matplotlib, which comes up with (sorry, don't know how to indent all of the below four spaces). Any ideas?
pip3 install matplotlib --user
Collecting matplotlib
Using cached https://files.pythonhosted.org/packages/9c/4b/06f4aa9bef6b5e4f177881b4dedd94faa6e7cb3d95dfaeaa8a1a8b541095/matplotlib-3.2.2.tar.gz
Collecting cycler>=0.10 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting kiwisolver>=1.0.1 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/62/b8/db619d97819afb52a3ff5ff6ad3f7de408cc83a8ec2dfb31a1731c0a97c2/kiwisolver-1.2.0.tar.gz
Complete output from command python setup.py egg_info:
warning: no files found matching '*.png' under directory 'docs/source'
no previously-included directories found matching '.git'
no previously-included directories found matching 'dist'
no previously-included directories found matching 'build'
no previously-included directories found matching 'docs/build'
zip_safe flag not set; analyzing archive contents...
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-c8bpoixa/cppy-1.1.0/setup.py", line 24, in <module>
'py/solver.cpp',
File "/usr/lib/python3.7/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 218, in run
os.path.join(archive_root, 'EGG-INFO'), self.zip_safe()
File "/usr/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 269, in zip_safe
return analyze_egg(self.bdist_dir, self.stubs)
File "/usr/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 379, in analyze_egg
safe = scan_module(egg_dir, base, name, stubs) and safe
File "/usr/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 416, in scan_module
code = marshal.load(f)
ValueError: bad marshal data (unknown type code)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-6x1f9zgp/kiwisolver/setup.py", line 80, in <module>
cmdclass={'build_ext': BuildExt},
File "/usr/lib/python3.7/site-packages/setuptools/__init__.py", line 128, in setup
_install_setup_requires(attrs)
File "/usr/lib/python3.7/site-packages/setuptools/__init__.py", line 123, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/usr/lib/python3.7/site-packages/setuptools/dist.py", line 461, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 866, in resolve
replace_conflicting=replace_conflicting
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1146, in best_match
return self.obtain(req, installer)
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1158, in obtain
return installer(requirement)
File "/usr/lib/python3.7/site-packages/setuptools/dist.py", line 528, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 672, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 698, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 881, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 1149, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 1135, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 253, in run_setup
raise
File "/usr/lib64/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/lib64/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 166, in save_modules
saved_exc.resume()
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 141, in resume
six.reraise(type, exc, self._tb)
File "/usr/lib/python3.7/site-packages/pkg_resources/_vendor/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/usr/lib/python3.7/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-c8bpoixa/cppy-1.1.0/setup.py", line 24, in <module>
'py/solver.cpp',
File "/usr/lib/python3.7/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 218, in run
os.path.join(archive_root, 'EGG-INFO'), self.zip_safe()
File "/usr/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 269, in zip_safe
return analyze_egg(self.bdist_dir, self.stubs)
File "/usr/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 379, in analyze_egg
safe = scan_module(egg_dir, base, name, stubs) and safe
File "/usr/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 416, in scan_module
code = marshal.load(f)
ValueError: bad marshal data (unknown type code)
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-6x1f9zgp/kiwisolver/
[ec2-user#ip-172-31-71-160 bin]$
Many of the dependencies of matplotlib have had new aarch64 wheels uploaded to pypi.org in the last few months since you posted this question. matplotlib itself doesn't have an aarch64 wheel available yet, but recently a change was merged to build one, so it probably will have one available soon. Even though matplotlib doesn't have a binary wheel published yet, I was able to install it on Ubuntu 20.04. It takes a minute or two to build, but it works:
$ sudo apt update
$ sudo apt install python3-pip
$ sudo pip3 install matplotlib
For completeness, I was able to get a full suite of python data science packages installed on Ubuntu 20.04 Arm with the following Dockerfile. (Just run the apt and pip commands if you aren't using Docker.) It takes a long time to complete since it builds many of these packages from source.
As more python packages begin publishing aarch64 wheels, this should become obsolete.
FROM ubuntu:focal
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
build-essential \
python3-pip \
python3-dev \
libfreetype-dev \
libopenblas64-dev \
mklibs \
libmlpack-dev \
libatlas-base-dev \
liblapack64-dev \
libffi-dev \
gfortran
RUN pip3 install jupyterlab matplotlib numpy pandas seaborn

Error with pip after upgrading : 'module' object has no attribute 'SSL_ST_INIT'

After upgrading pip, I try to do a 'pip freeze', but i've this error :
# pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 737kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-10.0.1
# pip freeze
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
Reading some post here, I found various solutions, but it's not working.
So I try another things, like installing using easy_install :
# sudo python -m easy_install --upgrade pyOpenSSL
Searching for pyOpenSSL
Reading https://pypi.python.org/simple/pyOpenSSL/
Best match: pyOpenSSL 18.0.0
Downloading https://files.pythonhosted.org/packages/9b/7c/ee600b2a9304d260d96044ab5c5e57aa489755b92bbeb4c0803f9504f480/pyOpenSSL-18.0.0.tar.gz#sha256=6488f1423b00f73b7ad5167885312bb0ce410d3312eb212393795b53c8caa580
Processing pyOpenSSL-18.0.0.tar.gz
Writing /tmp/easy_install-_qJ8_t/pyOpenSSL-18.0.0/setup.cfg
Running pyOpenSSL-18.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_qJ8_t/pyOpenSSL-18.0.0/egg-dist-tmp-KM4cDC
warning: no previously-included files found matching 'leakcheck'
warning: no previously-included files found matching 'codecov.yml'
warning: no previously-included files matching '*.py' found under directory 'leakcheck'
warning: no previously-included files matching '*.pem' found under directory 'leakcheck'
warning: no previously-included files matching '*.cert' found under directory 'examples/simple'
warning: no previously-included files matching '*.pkey' found under directory 'examples/simple'
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching '.travis'
no previously-included directories found matching '.mention-bot'
zip_safe flag not set; analyzing archive contents...
Adding pyOpenSSL 18.0.0 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/pyOpenSSL-18.0.0-py2.7.egg
Processing dependencies for pyOpenSSL
Searching for cryptography>=2.2.1
Reading https://pypi.python.org/simple/cryptography/
Best match: cryptography 2.2.2
Downloading https://files.pythonhosted.org/packages/ec/b2/faa78c1ab928d2b2c634c8b41ff1181f0abdd9adf9193211bd606ffa57e2/cryptography-2.2.2.tar.gz#sha256=9fc295bf69130a342e7a19a39d7bbeb15c0bcaabc7382ec33ef3b2b7d18d2f63
Processing cryptography-2.2.2.tar.gz
Writing /tmp/easy_install-rHRU6X/cryptography-2.2.2/setup.cfg
Running cryptography-2.2.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-rHRU6X/cryptography-2.2.2/egg-dist-tmp-eABQpn
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/dist-packages/easy_install.py", line 5, in <module>
main()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2199, in main
lambda: setup(
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2185, in with_ei_usage
return f()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2202, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 393, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 636, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 668, in install_item
self.process_distribution(spec, dist, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 716, in process_distribution
[requirement], self.local_index, self.easy_install
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 631, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 874, in best_match
return self.obtain(req, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 886, in obtain
return installer(requirement)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 636, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 666, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 856, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1078, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1063, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 68, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 114, in run
return func()
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 67, in runner
_execfile(setup_script, ns)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 43, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-rHRU6X/cryptography-2.2.2/setup.py", line 28, in <module>
RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools
and, so, upgrading 'setuptools' :
# sudo python -m easy_install --upgrade setuptools
Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Best match: setuptools 39.2.0
Downloading https://files.pythonhosted.org/packages/1a/04/d6f1159feaccdfc508517dba1929eb93a2854de729fa68da9d5c6b48fa00/setuptools-39.2.0.zip#sha256=f7cddbb5f5c640311eb00eab6e849f7701fa70bf6a183fc8a2c33dd1d1672fb2
Processing setuptools-39.2.0.zip
Writing /tmp/easy_install-wH5_qA/setuptools-39.2.0/setup.cfg
Running setuptools-39.2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-wH5_qA/setuptools-39.2.0/egg-dist-tmp-cpMLIT
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/dist-packages/easy_install.py", line 5, in <module>
main()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2199, in main
lambda: setup(
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2185, in with_ei_usage
return f()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2202, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 393, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 636, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 666, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 856, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1078, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1063, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 68, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 114, in run
return func()
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 67, in runner
_execfile(setup_script, ns)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 43, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-wH5_qA/setuptools-39.2.0/setup.py", line 195, in <module>
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 266, in __init__
_Distribution.__init__(self,attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 301, in finalize_options
ep.load()(self, ep.name, value)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2195, in load
raise ImportError("%r has no %r attribute" % (entry, attr))
ImportError: <module 'setuptools.dist' from '/usr/lib/python2.7/dist-packages/setuptools/dist.pyc'> has no 'check_specifier' attribute
And, the last try, using a specific version of pyOpenSSL :
# sudo pip install pyOpenSSL==16.2.0
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
Another idea to resolve this please ? :)
Thanks a lot.
F.
The problem is coming from pyopenssl. The first thing you can do is trying to remove and re-install pyopenssl :
apt-get --auto-remove --yes remove python-openssl
pip install pyOpenSSL
But it also could be a path problem.
Upgrading the OS-provided pip is a well-known 'own goal' and should be avoided unless absolutely necessary.
First, you may need to re-install the OS package, to restore normal use of the 'pip' command.
If you must have a newer pip: try installing it from a self-contained installer, see here: https://pip.pypa.io/en/stable/installing/ and not with the existing pip. Unless you must have it available for all users, run the install with '--user' option - and use the same option when installing packages with pip - that way you leave the OS-provided Python and pip things alone and don't overwrite them and can always return to them by deleting everything Python-related from ~/.local/.
In all cases, after you recover from pip being stuck as you have it right now, try upgrading pyOpenSSL first (or pip install-ing it with --user).
Another helpful tip that I found somewhere on the Web: always use python -m pip instead of running pip directly, this avoids problems with pip picking up the wrong version or the pip module (or running the wrong python executable, if you've got more than one).

MemoryError When Installing tzwhere

On an AWS EC2, I cloned pytzwhere using:
sudo git clone --recursive https://github.com/pegler/pytzwhere.git
Then I tried to install it using Python 2.7 and:
sudo python setup.py install
Unfortunately it stops with the following error:
...
Extracting tzwhere-2.2-py2.7.egg to /usr/local/lib/python2.7/site-packages
Traceback (most recent call last):
File "setup.py", line 32, in <module>
'Topic :: Software Development :: Localization',
File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/usr/lib/python2.7/dist-packages/setuptools/command/install.py", line 117, in do_egg_install
cmd.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 393, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 623, in easy_install
return self.install_item(None, spec, tmpdir, deps, True)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 672, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 820, in install_eggs
return [self.install_egg(dist_filename, tmpdir)]
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 900, in install_egg
os.path.dirname(destination)))
File "/usr/lib64/python2.7/distutils/cmd.py", line 349, in execute
util.execute(func, args, msg, dry_run=self.dry_run)
File "/usr/lib64/python2.7/distutils/util.py", line 309, in execute
func(*args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1177, in unpack_and_compile
unpack_archive(egg_path, destination, pf)
File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 50, in unpack_archive
driver(filename, extract_dir, progress_filter)
File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 117, in unpack_zipfile
data = z.read(info.filename)
File "/usr/lib64/python2.7/zipfile.py", line 935, in read
return self.open(name, "r", pwd).read()
File "/usr/lib64/python2.7/zipfile.py", line 630, in read
data = self.read1(n)
File "/usr/lib64/python2.7/zipfile.py", line 684, in read1
max(n - len_readbuffer, self.MIN_READ_SIZE)
MemoryError
I'll appreciate it if you guide me how to solve this problem.

Error when installing rpy2 module in Python with easy_install

I've been trying to install the rpy2 module so I can use R functions inside my Python script, but I'm getting an error after following the advice from these pages:
1) Tried to guess R's HOME but no R command in the PATH. OsX 10.6
2) http://rpy.sourceforge.net/rpy2/doc-dev/html/overview.html
What I've done so far:
1) Edited my path environment variable to include "C:\Program Files\R\R-3.1.0\bin\x64;"
2) Created a new environment variable called "R_HOME" and set its value to "C:\Program Files\R\R-3.1.0"
3) Created a new environment variable called "R_USER" and set its value to "Hefin" (my windows username)
Then in my command prompt I type:
easy_install rpy2
As far as I'm aware, easy_install is setup and installed correctly.
The output I get is:
Searching for rpy2
Reading https://pypi.python.org/simple/rpy2/
Best match: rpy2 2.5.5
Downloading https://pypi.python.org/packages/source/r/rpy2/rpy2-2.5.5.tar.gz#md5=c874bebbe775e3cdc926a1da00252c37
Processing rpy2-2.5.5.tar.gz
Writing C:\Users\Hefin\AppData\Local\Temp\easy_install-98mu0_xn\rpy2-2.5.5\setup.cfg
Running rpy2-2.5.5\setup.py -q bdist_egg --dist-dir C:\Users\Hefin\AppData\Local\Temp\easy_install-98mu0_xn\rpy2-2.5.5\egg-dist-tmp-00qpf_z8
The system cannot find the path specified.
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 150, in save_modules
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 191, in setup_context
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 235, in run_setup
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 265, in run
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 234, in runner
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 46, in _execfile
File "C:\Users\Hefin\AppData\Local\Temp\easy_install-98mu0_xn\rpy2-2.5.5\setup.py", line 282, in <module>
File "C:\Users\Hefin\AppData\Local\Temp\easy_install-98mu0_xn\rpy2-2.5.5\setup.py", line 185, in getRinterface_ext
File "C:\Users\Hefin\AppData\Local\Temp\easy_install-98mu0_xn\rpy2-2.5.5\setup.py", line 106, in version
File "C:\Python34\lib\subprocess.py", line 620, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command '('C:\\PROGRA~1\\R\\R-31~1.0\\bin\\R', '--version')' returned non-zero exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\Scripts\easy_install-script.py", line 9, in <module>
load_entry_point('setuptools==12.0.5', 'console_scripts', 'easy_install')()
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\command\easy_install.py", line 2244, in main
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\command\easy_install.py", line 374, in run
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\command\easy_install.py", line 623, in easy_install
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\command\easy_install.py", line 653, in install_item
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\command\easy_install.py", line 838, in install_eggs
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\command\easy_install.py", line 1066, in build_and_install
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\command\easy_install.py", line 1052, in run_setup
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 238, in run_setup
File "C:\Python34\lib\contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 191, in setup_context
File "C:\Python34\lib\contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 162, in save_modules
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 137, in resume
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\compat.py", line 65, in reraise
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 150, in save_modules
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 191, in setup_context
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 235, in run_setup
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 265, in run
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 234, in runner
File "C:\Python34\lib\site-packages\setuptools-12.0.5-py3.4.egg\setuptools\sandbox.py", line 46, in _execfile
File "C:\Users\Hefin\AppData\Local\Temp\easy_install-98mu0_xn\rpy2-2.5.5\setup.py", line 282, in <module>
File "C:\Users\Hefin\AppData\Local\Temp\easy_install-98mu0_xn\rpy2-2.5.5\setup.py", line 185, in getRinterface_ext
File "C:\Users\Hefin\AppData\Local\Temp\easy_install-98mu0_xn\rpy2-2.5.5\setup.py", line 106, in version
File "C:\Python34\lib\subprocess.py", line 620, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command '('C:\\PROGRA~1\\R\\R-31~1.0\\bin\\R', '--version')' returned non-zero exit status 1
C:\Users\Hefin>
Sorry it's so verbose! If I then invoke python and try to import the rpy module, I get:
>>> import python
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'python'
>>>
I'm afraid I'm new to Python and I don't know what I'm doing wrong. I've searched through previous forum posts, but none seem to have this problem. I'm using a 64bit machine with Windows 7, Python3.4 and R3.1.0.
Any help or thoughts would be much appreciated as I'm sure it's just something simple I'm doing wrong.
Thank you!
Hefin
There's a much easier way to go about this - install rpy2 from Christoph Gohlke's Python Extension Packages for Windows repository here. Download the rpy2‑2.5.5‑cp34‑none‑win_amd64.whl file (the current version at the time of this writing), change to the download folder on the command line, and run
pip install rpy2‑2.5.5‑cp34‑none‑win_amd64.whl
pip is already included in Python 3.4, and should be used instead of easy_install when installing new modules, as easy_install is deprecated.
Installing rpy2 on windows is straight forward using conda
conda install rpy2

easy_install can't install package

I'm trying to write a setup.py file for my python project:
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
requires = [
'requests',
'simplejson',
'logging',
'rfc3987',
]
setup(name='xxxxxxx',
version='0.1',
description='xxxxxxx API',
url='https://github.com/xxxxxxxx',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=requires,
)
When I execute it I'm getting this error:
Searching for rfc3987
Reading http://pypi.python.org/simple/rfc3987/
Best match: rfc3987 1.3.1
Downloading https://pypi.python.org/packages/source/r/rfc3987/rfc3987-1.3.1.tar.gz#md5=397b1c1cd8b934269e53a621d56d9ed2
Processing rfc3987-1.3.1.tar.gz
Running rfc3987-1.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-AYV_bv/rfc3987-1.3.1/egg-dist-tmp-G8Kbay
Traceback (most recent call last):
File "/usr/bin/easy_install", line 9, in <module>
load_entry_point('distribute==0.6.10', 'console_scripts', 'easy_install')()
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 1715, in main
with_ei_usage(lambda:
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 1696, in with_ei_usage
return f()
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 1719, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 236, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 472, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 502, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 681, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 958, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 947, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.6/site-packages/setuptools/sandbox.py", line 29, in run_setup
lambda: execfile(
File "/usr/lib/python2.6/site-packages/setuptools/sandbox.py", line 70, in run
return func()
File "/usr/lib/python2.6/site-packages/setuptools/sandbox.py", line 31, in <lambda>
{'__file__':setup_script, '__name__':'__main__'}
File "setup.py", line 4, in <module>
File "/tmp/easy_install-AYV_bv/rfc3987-1.3.1/rfc3987.py", line 324, in <module>
File "/tmp/easy_install-AYV_bv/rfc3987-1.3.1/rfc3987.py", line 323, in <genexpr>
File "/tmp/easy_install-AYV_bv/rfc3987-1.3.1/rfc3987.py", line 319, in _interpret_unicode_escapes
ValueError: zero length field name in format
If I try just easy_install rfc3987 I'm getting the same error.
Are there any ways to go around this?
rfc3987 claims that it works on Python 2.7 and 3.x. You're trying to install it on 2.6. So it fails.
The problem has nothing to do with your own package, or with easy_install. If you download the tarball manually and run python2.6 setup.py install, you get the same error. And in fact, at least in 1.3.1, there's code that clearly isn't legal under Python 2.6, like this function.
From the git history, it looks like there have been changes to make it Python 2.6 compatible, so the next release may work. Until then, you won't be able to use it from 2.6.

Categories

Resources