Pip installation causes RecursionError - python

I am trying to install a software called grizli (https://github.com/gbrammer/grizli/) in a conda environment. In one step I have to install another software called drizzle (https://github.com/gbrammer/drizzle.git). Thís installation always results in a RecursionError. As explained in the installation instructions I run
pip install git+https://github.com/gbrammer/drizzle.git
resulting in
Collecting git+https://github.com/gbrammer/drizzle.git
Cloning https://github.com/gbrammer/drizzle.git to /tmp/pip-req-build-ncjb9u8_
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-ncjb9u8_/setup.py", line 61, in <module>
cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE)
File "/tmp/pip-req-build-ncjb9u8_/astropy_helpers/astropy_helpers/setup_helpers.py", line 140, in register_commands
from .commands.build_sphinx import AstropyBuildSphinx, AstropyBuildDocs
File "/tmp/pip-req-build-ncjb9u8_/astropy_helpers/astropy_helpers/commands/build_sphinx.py", line 16, in <module>
from sphinx.setup_command import BuildDoc as SphinxBuildDoc
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/sphinx/setup_command.py", line 23, in <module>
from sphinx.application import Sphinx
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/sphinx/application.py", line 34, in <module>
from sphinx.environment import BuildEnvironment
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 38, in <module>
from sphinx.util.websupport import is_commentable
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/sphinx/util/websupport.py", line 11, in <module>
from sphinxcontrib.websupport.utils import is_commentable # NOQA
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/sphinxcontrib/websupport/__init__.py", line 15, in <module>
from sphinxcontrib.websupport.core import WebSupport # NOQA
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/sphinxcontrib/websupport/core.py", line 17, in <module>
from jinja2 import Environment, FileSystemLoader
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/jinja2/environment.py", line 15, in <module>
from jinja2 import nodes
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/jinja2/nodes.py", line 19, in <module>
from jinja2.utils import Markup
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/site-packages/jinja2/utils.py", line 486, in <module>
MutableMapping.register(LRUCache)
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/abc.py", line 158, in register
if issubclass(subclass, cls):
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/abc.py", line 209, in __subclasscheck__
ok = cls.__subclasshook__(subclass)
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/typing.py", line 884, in __extrahook__
if issubclass(subclass, scls):
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/typing.py", line 1154, in __subclasscheck__
return super().__subclasscheck__(cls)
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/abc.py", line 209, in __subclasscheck__
ok = cls.__subclasshook__(subclass)
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/typing.py", line 884, in __extrahook__
if issubclass(subclass, scls):
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/typing.py", line 1154, in __subclasscheck__
return super().__subclasscheck__(cls)
...
...
...
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/abc.py", line 209, in __subclasscheck__
ok = cls.__subclasshook__(subclass)
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/typing.py", line 884, in __extrahook__
if issubclass(subclass, scls):
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/typing.py", line 1154, in __subclasscheck__
return super().__subclasscheck__(cls)
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/abc.py", line 209, in __subclasscheck__
ok = cls.__subclasshook__(subclass)
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/typing.py", line 884, in __extrahook__
if issubclass(subclass, scls):
File "/home/username/anaconda3/envs/grizli-dev/lib/python3.6/typing.py", line 1154, in __subclasscheck__
return super().__subclasscheck__(cls)
RecursionError: maximum recursion depth exceeded while calling a Python object
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-ncjb9u8_/
The three points in the code stand for the repetition of the three lines that always appear in the same order and probably cause the RecursionError.
I have already tried different pip versions but it didn't change anything. Does anybody have an idea?

I just got the same issue. The only solution that worked for me was to downgrade sphinx to a version <=1.5.6 as mentioned here: https://github.com/ericmandel/pyds9/issues/53 (note that I already had astro-helpers >=2.0 when I got the issue, so the solution is on downgrading sphinx)
Just do: pip install sphinx==1.5.6
and then hopefully drizzle will install correctly.

Related

pipenv virtual environment error with package install

I am new to using pipenv virtual environments. I am using one with a Django project. Recently I tried to start the environment with pipenv shell. I got a message that something like there was no environment available even though I have been using it for several months.
I exited the directory and re-entered. Then ran pipenv shell again. This time the env was activated. However when I try to install a package or run pipenv lock --clear I get the following error:
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!
Traceback (most recent call last):
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/resolver.py", line 764, in <module>
main()
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/resolver.py", line 758, in main
_main(parsed.pre, parsed.clear, parsed.verbose, parsed.system, parsed.write,
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/resolver.py", line 741, in _main
resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/resolver.py", line 695, in resolve_packages
from pipenv.core import project
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/core.py", line 33, in <module>
from .project import Project
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/project.py", line 30, in <module>
from .vendor.requirementslib.models.utils import get_default_pyproject_backend
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/requirementslib/__init__.py", line 9, in <module>
from .models.lockfile import Lockfile
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/requirementslib/models/lockfile.py", line 14, in <module>
from ..utils import is_editable, is_vcs, merge_items
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/requirementslib/utils.py", line 8, in <module>
import pip_shims.shims
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/__init__.py", line 26, in <module>
from . import shims
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/shims.py", line 12, in <module>
from .models import (
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 790, in <module>
Command.add_mixin(SessionCommandMixin)
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 704, in add_mixin
mixin = mixin.shim()
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 752, in shim
result = self.traverse(top_path)
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 744, in traverse
result = shim.shim()
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 590, in shim
imported = self._import()
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 615, in _import
result = self._import_module(self.calculated_module_path)
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 365, in _import_module
imported = importlib.import_module(module)
File "/Users/mainuser/.pyenv/versions/3.9.2/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/cli/req_command.py", line 15, in <module>
from pipenv.patched.notpip._internal.index.package_finder import PackageFinder
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/index/package_finder.py", line 21, in <module>
from pipenv.patched.notpip._internal.index.collector import parse_links
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/index/collector.py", line 12, in <module>
from pipenv.patched.notpip._vendor import html5lib, requests
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/requests/__init__.py", line 97, in <module>
from pipenv.patched.notpip._vendor.urllib3.contrib import pyopenssl
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/Users/mainuser/anaconda/lib/python3.6/site-packages/OpenSSL/rand.py", line 213, in <module>
_lib.ERR_load_RAND_strings()
AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'
I am not sure how to interpret this but it looks like python3.6 is being used when the shell and project python version is 3.9.
Any ideas about what is causing this and how to fix it?

OpenAI Gym - AttributeError: module 'contextlib' has no attribute 'nullcontext'

I'm running into this error when trying to run a command from docker a docker container on google compute engine.
Here's the stacktrace:
Traceback (most recent call last):
File "train.py", line 16, in <module>
from stable_baselines.ppo1 import PPO1
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/__init__.py", line 3, in <module>
from stable_baselines.a2c import A2C
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/a2c/__init__.py", line 1, in <module>
from stable_baselines.a2c.a2c import A2C
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/a2c/a2c.py", line 3, in <module>
import gym
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/__init__.py", line 13, in <module>
from gym.envs import make, spec, register
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/envs/__init__.py", line 10, in <module>
_load_env_plugins()
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 269, in load_env_plugins
context = contextlib.nullcontext()
AttributeError: module 'contextlib' has no attribute 'nullcontext'
It seems like this is an issue with python 3.6 and gym. Upgrading my container to python 3.7 fixed the issue.
Degrading the version of gym may also solve this problem. I met this error with python 3.6, too. And I degraded gym's version from 0.21.0 to 0.15.7, then it was fixed.
You need a specific gym version (==0.15.7) to run contextlib,
I also have this error, and resolved by set the specific pytest version to pytest==7.0.1
Traceback (most recent call last):
File "setup.py", line 24, in <module>
tests_require=['pytest-mock', 'pytest-cov', 'pytest==7.1.2', 'mock', 'tomli==1.2.2', 'coverage==6.4']
File "/opt/teamcity/work/dd131e9564caa7d5/venv/lib64/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/opt/teamcity/work/dd131e9564caa7d5/.eggs/pytest_runner-6.0.0-py3.6.egg/ptr/__init__.py", line 203, in run
return self.run_tests()
File "/opt/teamcity/work/dd131e9564caa7d5/.eggs/pytest_runner-6.0.0-py3.6.egg/ptr/__init__.py", line 214, in run_tests
result_code = __import__('pytest').main()
File "/opt/teamcity/work/dd131e9564caa7d5/.eggs/pytest-7.1.2-py3.6.egg/pytest/__init__.py", line 28, in <module>
from _pytest.logging import LogCaptureFixture
File "/opt/teamcity/work/dd131e9564caa7d5/.eggs/pytest-7.1.2-py3.6.egg/_pytest/logging.py", line 7, in <module>
from contextlib import nullcontext
ImportError: cannot import name 'nullcontext'

Conda crashes after installing one package - OSError: /lib64/liblzma.so.5: version `XZ_5.2' not found

I used coda for a long time, with limited problems.
However, I recently installed Miniconda2 (Miniconda2-latest-Linux-x86_64.sh) on a HPC node.
Everything works fine, but I can not install multiple packages.
What happens, is that I install one package, and after that, I get the following error when I try to install a new one:
Traceback (most recent call last):
File "/hpc-home/ro/miniconda2/bin/conda", line 13, in <module>
sys.exit(main())
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/cli/main.py", line 150, in main
return conda_exception_handler(_main, *args, **kwargs)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1335, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1046, in __call__
return self.handle_exception(exc_val, exc_tb)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1090, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1101, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1171, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/cli/main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/core/index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/core/package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda_package_handling/api.py", line 3, in <module>
from libarchive.exception import ArchiveError as _LibarchiveArchiveError
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/libarchive/__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/libarchive/entry.py", line 6, in <module>
from . import ffi
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/libarchive/ffi.py", line 27, in <module>
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
File "/hpc-home/ro/miniconda2/lib/python2.7/ctypes/__init__.py", line 444, in LoadLibrary
return self._dlltype(name)
File "/hpc-home/ro/miniconda2/lib/python2.7/ctypes/__init__.py", line 366, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /lib64/liblzma.so.5: version `XZ_5.2' not found (required by /hpc-home/ro/miniconda2/lib/libarchive.so.13)
The problem is temporally fixed when I re-install conda:
bash Miniconda2-latest-Linux-x86_64.sh -u
I am not sure what I am missing here. Would someone point me towards a potential solution not involving using sudo, as I have no rights?

Installing pymongo on a nitrous.io box

I'm fairly new to Python, and Nitrous.IO, and MongoDB, and command line in general so would appreciate a little guidance here if possible.
I'm trying to install pymongo on my Nitrous.IO box but can't seem to find a way to do it - this tutorial suggests 'import pymongo' but that didn't work (see below).
I can't seem to find any tutorials or help on this - a google search for "install +pymongo with nitrous.io" gave me 0 results.
action#thirdyearproject-148753:~(master*)$ import pymongo
import: unable to open X server `' # error/import.c/ImportImageCommand/366.
action#thirdyearproject-148753:~(master*)$ pip install pymongo
Traceback (most recent call last):
File "/home/action/.parts/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 2431, in load_entry_point
return ep.load()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 2147, in load
['__name__'])
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/__init__.py", line 10, in <modul
from pip.util import get_installed_distributions, get_prog
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/util.py", line 15, in <module>
from pip.locations import site_packages, running_under_virtualenv, virtualenv_no_global
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/locations.py", line 96, in <modu
build_prefix = _get_build_prefix()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/locations.py", line 64, in _get_
path = os.path.join(tempfile.gettempdir(), 'pip_build_%s' %
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/tempfile.py", line 269, in gettempdir
tempdir = _get_default_tempdir()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/tempfile.py", line 212, in _get_default_tempdir
("No usable temporary directory found in %s" % dirlist))
IOError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/action']
action#thirdyearproject-148753:~(master*)$ easy_install pymongo
Traceback (most recent call last):
File "/home/action/.parts/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 2829, in <module>
working_set = WorkingSet._build_master()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 451, in _build_master
return cls._build_from_requirements(__requires__)
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 464, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 639, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: setuptools==2.2
action#thirdyearproject-148753:~(master*)$ parts install pymongo
parts: ERROR: Package "pymongo" not found
Aborting!
Does anyone know how I would go about installing this? It's starting to be a real pain!
You might be able to install it withpip using this advice. Once you've done that, you would use the import pymongo at the top of your code file.

Python Cmd/Powershell error "Traceback (Most recent call last)"

I was giving a look at the "Learn Python The Hard Way" tutorial and when it told me to try it out by typing Python in Powershell after I installed it just kept giving me this:
PS C:\Users\Zach> python
Traceback (most recent call last):
File "C:\Python27\lib\site.py", line 548, in <module>
main()
File "C:\Python27\lib\site.py", line 530, in main
known_paths = addusersitepackages(known_paths)
File "C:\Python27\lib\site.py", line 266, in addusersitepackages
user_site = getusersitepackages()
File "C:\Python27\lib\site.py", line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "C:\Python27\lib\site.py", line 231, in getuserbase
USER_BASE = get_config_var('userbase')
File "C:\Python27\lib\sysconfig.py", line 516, in get_config_var
return get_config_vars().get(name)
File "C:\Python27\lib\sysconfig.py", line 449, in get_config_vars
import re
File "C:\Python27\lib\re.py", line 105, in <module>
import sre_compile
File "C:\Python27\lib\sre_compile.py", line 14, in <module>
import sre_parse
File "C:\Python27\lib\sre_parse.py", line 17, in <module>
from sre_constants import *
File "C:\Python27\lib\sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
I also tried running through the command prompt and got the same error. I've installed and uninstalled python about 3 times and have done a few reboots to no avail. I am very new to python and I'm confused on what to do here. I would also appreciate any links to other python tutorials.
In this case, from my understanding, you have no modules called "MAXREPEAT" or you(or the installer) have installed it somewhere wrong. A reinstallation or redirecting the path should get it to work.

Categories

Resources