Python h5py installation problems - python

I'm attempting to follow this project: https://github.com/MasazI/cnn_depth_tensorflow
The issue is I don't have h5py. So I do pip install h5py. Then I get this:
Traceback (most recent call last):
File "convert_mat_to_img.py", line 4, in <module>
import h5py
ImportError: No module named h5py
MBP-R-006:cnn_depth_tensorflow-master admin2$ pip install h5py
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2691, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2322, in load
return self.resolve()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2328, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/__init__.py", line 5, in <module>
import logging
File "/usr/local/Cellar/python#2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 626, in <module>
_handlers = weakref.WeakValueDictionary() #map of handler names to handlers
File "/usr/local/Cellar/python#2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 55, in __init__
def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
NameError: global name '_remove_dead_weakref' is not defined
Is my version of python on my OS X messed up/needing modifications? How can I fix this?
EDIT:
I just typed 'pip -V' and this is what I get:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2691, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2322, in load
return self.resolve()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2328, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/__init__.py", line 5, in <module>
import logging
File "/usr/local/Cellar/python#2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 626, in <module>
_handlers = weakref.WeakValueDictionary() #map of handler names to handlers
File "/usr/local/Cellar/python#2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 55, in __init__
def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
NameError: global name '_remove_dead_weakref' is not defined

Related

AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' when running conda commands on AWS SageMaker

I am working on AWS SageMaker and simply trying to run
conda env list
and getting the error
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
(Note that when I e.g. run conda list it works). I found multiple questions regarding this and tried e.g.
pip install pip --upgrade
pip install pyopenssl --upgrade
as stated in this answer.
However, I am still getting the same error.
Any help on how can I solve this?
FYI: the complete error message is as follows
Traceback (most recent call last):
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/exceptions.py", line 1079, in __call__
return func(*args, **kwargs)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/cli/main.py", line 84, in _main
exit_code = do_call(args, p)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/cli/conda_argparse.py", line 81, in do_call
module = import_module(relative_mod, __name__.rsplit('.', 1)[0])
File "/home/ec2-user/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/cli/main_update.py", line 8, in <module>
from .install import install
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/cli/install.py", line 19, in <module>
from ..core.index import calculate_channel_urls, get_index
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/core/index.py", line 10, in <module>
from .package_cache_data import PackageCacheData
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/core/package_cache_data.py", line 14, in <module>
from .path_actions import CacheUrlAction, ExtractPackageAction
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/core/path_actions.py", line 30, in <module>
from ..gateways.connection.download import download
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/gateways/connection/download.py", line 18, in <module>
from .session import CondaSession
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/gateways/connection/session.py", line 13, in <module>
from .adapters.s3 import S3Adapter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/gateways/connection/adapters/s3.py", line 12, in <module>
import boto3
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/boto3/__init__.py", line 17, in <module>
from boto3.session import Session
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/boto3/session.py", line 17, in <module>
import botocore.session
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/session.py", line 26, in <module>
import botocore.client
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/client.py", line 15, in <module>
from botocore import waiter, xform_name
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/waiter.py", line 18, in <module>
from botocore.docs.docstring import WaiterDocstring
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/__init__.py", line 15, in <module>
from botocore.docs.service import ServiceDocumenter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/service.py", line 14, in <module>
from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/client.py", line 14, in <module>
from botocore.docs.example import ResponseExampleDocumenter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/example.py", line 13, in <module>
from botocore.docs.shape import ShapeDocumenter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/shape.py", line 19, in <module>
from botocore.utils import is_json_value_header
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/utils.py", line 35, in <module>
import botocore.httpsession
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/httpsession.py", line 46, in <module>
from urllib3.contrib.pyopenssl import (
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 50, in <module>
import OpenSSL.SSL
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/OpenSSL/crypto.py", line 1517, in <module>
class X509StoreFlags(object):
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/OpenSSL/crypto.py", line 1537, in X509StoreFlags
CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ec2-user/anaconda3/condabin/conda", line 13, in <module>
sys.exit(main())
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/cli/main.py", line 152, in main
return conda_exception_handler(_main, *args, **kwargs)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/exceptions.py", line 1371, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/exceptions.py", line 1082, in __call__
return self.handle_exception(exc_val, exc_tb)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/exceptions.py", line 1126, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/exceptions.py", line 1137, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/exceptions.py", line 1207, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/cli/main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/core/index.py", line 10, in <module>
from .package_cache_data import PackageCacheData
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/core/package_cache_data.py", line 14, in <module>
from .path_actions import CacheUrlAction, ExtractPackageAction
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/core/path_actions.py", line 30, in <module>
from ..gateways.connection.download import download
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/gateways/connection/download.py", line 18, in <module>
from .session import CondaSession
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/gateways/connection/session.py", line 13, in <module>
from .adapters.s3 import S3Adapter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/conda/gateways/connection/adapters/s3.py", line 12, in <module>
import boto3
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/boto3/__init__.py", line 17, in <module>
from boto3.session import Session
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/boto3/session.py", line 17, in <module>
import botocore.session
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/session.py", line 26, in <module>
import botocore.client
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/client.py", line 15, in <module>
from botocore import waiter, xform_name
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/waiter.py", line 18, in <module>
from botocore.docs.docstring import WaiterDocstring
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/__init__.py", line 15, in <module>
from botocore.docs.service import ServiceDocumenter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/service.py", line 14, in <module>
from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/client.py", line 14, in <module>
from botocore.docs.example import ResponseExampleDocumenter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/example.py", line 13, in <module>
from botocore.docs.shape import ShapeDocumenter
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/docs/shape.py", line 19, in <module>
from botocore.utils import is_json_value_header
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/utils.py", line 35, in <module>
import botocore.httpsession
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/botocore/httpsession.py", line 46, in <module>
from urllib3.contrib.pyopenssl import (
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 50, in <module>
import OpenSSL.SSL
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/OpenSSL/crypto.py", line 1517, in <module>
class X509StoreFlags(object):
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/OpenSSL/crypto.py", line 1537, in X509StoreFlags
CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

anaconda3/bin/python: undefined symbol: archive_errno

I installed Anaconda 4.7.10 on Ubuntu 16.04.2 LTS and everything worked smoothly.
After a couple of days I wanted to install "sqlalchemy" but this time I got the error message below. Since then almost every conda command yields the message below. Includingconda update --all and conda upgrade.
Any suggestions?
Traceback (most recent call last):
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 1062, in __call__
return func(*args, **kwargs)
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 84, in _main
exit_code = do_call(args, p)
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 80, in do_call
module = import_module(relative_mod, __name__.rsplit('.', 1)[0])
File "/home/martin/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 8, in <module>
from .install import install
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 19, in <module>
from ..core.index import calculate_channel_urls, get_index
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/core/index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/core/package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda_package_handling/api.py", line 3, in <module>
from libarchive.exception import ArchiveError as _LibarchiveArchiveError
File "/home/martin/anaconda3/lib/python3.6/site-packages/libarchive/__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "/home/martin/anaconda3/lib/python3.6/site-packages/libarchive/entry.py", line 6, in <module>
from . import ffi
File "/home/martin/anaconda3/lib/python3.6/site-packages/libarchive/ffi.py", line 108, in <module>
errno = ffi('errno', [c_archive_p], c_int)
File "/home/martin/anaconda3/lib/python3.6/site-packages/libarchive/ffi.py", line 95, in ffi
f = getattr(libarchive, 'archive_'+name)
File "/home/martin/anaconda3/lib/python3.6/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/home/martin/anaconda3/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /home/martin/anaconda3/bin/python: undefined symbol: archive_errno
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/martin/anaconda3/bin/conda", line 13, in <module>
sys.exit(main())
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 150, in main
return conda_exception_handler(_main, *args, **kwargs)
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 1354, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 1065, in __call__
return self.handle_exception(exc_val, exc_tb)
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 1109, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 1120, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 1190, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/cli/main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/core/index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda/core/package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda_package_handling/api.py", line 7, in <module>
from .tarball import CondaTarBZ2 as _CondaTarBZ2
File "/home/martin/anaconda3/lib/python3.6/site-packages/conda_package_handling/tarball.py", line 7, in <module>
import libarchive
File "/home/martin/anaconda3/lib/python3.6/site-packages/libarchive/__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "/home/martin/anaconda3/lib/python3.6/site-packages/libarchive/entry.py", line 6, in <module>
from . import ffi
File "/home/martin/anaconda3/lib/python3.6/site-packages/libarchive/ffi.py", line 108, in <module>
errno = ffi('errno', [c_archive_p], c_int)
File "/home/martin/anaconda3/lib/python3.6/site-packages/libarchive/ffi.py", line 95, in ffi
f = getattr(libarchive, 'archive_'+name)
File "/home/martin/anaconda3/lib/python3.6/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/home/martin/anaconda3/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /home/martin/anaconda3/bin/python: undefined symbol: archive_errno
I've came across the same error on my conda installation in windows subsystem for linux and could solve it by installing libarchive-dev. This seems to be some kind of hidden dependency, libarchive was not installed on my system previously.
apt-get install libarchive-dev

No module named misc when implementing a simple pytest plugin?

I'm trying to implement the pytest plugin mentioned in https://github.com/pytest-dev/pytest/issues/2039, basically this plugin will print all tests that pytest finds:
## pytest_collector.py
import sys
import pytest
class DkPytestCollector(object):
def __init__(self):
self.collected = []
def pytest_collection_modifyitems(self, items):
for item in items:
self.collected.append(item.nodeid)
if __name__ == '__main__':
dkpytest_collector = DkPytestCollector()
directory = sys.argv[1]
pytest.main(['--collect-only', directory], plugins=[dkpytest_collector])
print('\n\nfound:')
for nodeid in dkpytest_collector.collected:
print(nodeid)
however, when I run it I get:
(dk) go|c:\srv\lib\dk> python ..\dkbuild\dkbuild\pytest_collector.py \srv\lib\dk
Traceback (most recent call last):
File "..\dkbuild\dkbuild\pytest_collector.py", line 20, in <module>
pytest.main(['--collect-only', directory], plugins=[dkpytest_collector])
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 50, in main
config = _prepareconfig(args, plugins)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 160, in _prepareconfig
pluginmanager=pluginmanager, args=args)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 617, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
firstresult=hook.spec_opts.get('firstresult'),
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 196, in _multicall
gen.send(outcome)
File "c:\srv\venv\dk\lib\site-packages\_pytest\helpconfig.py", line 68, in pytest_cmdline_parse
config = outcome.get_result()
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 77, in get_result
_reraise(*ex) # noqa
File "c:\srv\venv\dk\lib\site-packages\pluggy\callers.py", line 180, in _multicall
res = hook_impl.function(*args)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 943, in pytest_cmdline_parse
self.parse(args)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 1108, in parse
self._preparse(args, addopts=addopts)
File "c:\srv\venv\dk\lib\site-packages\_pytest\config.py", line 1071, in _preparse
self.pluginmanager.load_setuptools_entrypoints('pytest11')
File "c:\srv\venv\dk\lib\site-packages\pluggy\__init__.py", line 397, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\srv\venv\dk\lib\site-packages\pkg_resources\__init__.py", line 2405, in load
return self.resolve()
File "c:\srv\venv\dk\lib\site-packages\pkg_resources\__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "c:\srv\venv\dk\lib\site-packages\_pytest\assertion\rewrite.py", line 212, in load_module
py.builtin.exec_(co, mod.__dict__)
File "c:\srv\venv\dk\lib\site-packages\py\_builtin.py", line 221, in exec_
exec2(obj, globals, locals)
File "<string>", line 7, in exec2
File "c:\srv\venv\dk\lib\site-packages\pytest_cov\plugin.py", line 6, in <module>
from coverage.misc import CoverageException
ImportError: No module named misc
if I pip uninstall pytest-cov everything works (well, except no coverage..)
How do I get this to work without uninstalling pytest-cov?

Python Click command doesn't recognize options

I am trying to register command-line options in Click. Everything is working fine until I add the params argument to the constructor.
class InitCommand(click.Command):
def __init__(self):
super().__init__(
name='init',
short_help='Initialize the needed scaffolding.',
help='something helpful, but longer',
# params=[] ### <-- Works fine
params=[click.Option('--force', default=False)]
)
I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/aquapy", line 11, in <module>
load_entry_point('aquapy-cli', 'console_scripts', 'aquapy')()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
return self.resolve()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Users/******/__main__.py", line 3, in <module>
from .bootstrap import main
File "/Users/******/bootstrap.py", line 17, in <module>
main.add_command(InitCommand())
File "/Users/******/commands/init_command.py", line 10, in __init__
params=[click.Option('--force', default=False)]
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1460, in __init__
Parameter.__init__(self, param_decls, type=type, **attrs)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1266, in __init__
self._parse_decls(param_decls or (), expose_value)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1533, in _parse_decls
raise TypeError('Name defined twice')
TypeError: Name defined twice
The issue is that click.Option() expects the first argument to a list and is not like the decorator version #click.option().
params=[click.Option(['--force'], default=False)]
Wrapping the command option in a list solved the problem.

Virtualenv returning "No such file or directory" [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I've had many properly working virtualenvs, but from today, they give me an error.
I've tried reinstalling pip and virtualenvwrapper with easy_install -U, but the error remained. Any ideas?
$ mkvirtualenv django
sh: 0: getcwd() failed: No such file or directory
New python executable in django/bin/python
Installing setuptools.............done.
Installing pip...............done.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
from stevedore import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/__init__.py", line 1, in <module>
from .extension import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/extension.py", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2697, in <module>
_declare_state('object', working_set = WorkingSet())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 435, in __init__
self.add_entry(entry)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 450, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1723, in find_on_path
path_item = _normalize_cached(path_item)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1872, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1866, in normalize_path
return os.path.normcase(os.path.realpath(filename))
File "/usr/lib/python2.7/posixpath.py", line 375, in realpath
return abspath(filename)
File "/usr/lib/python2.7/posixpath.py", line 347, in abspath
cwd = os.getcwd()
OSError: [Errno 2] No such file or directory
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 70, in apport_excepthook
binary = os.path.realpath(os.path.join(os.getcwdu(), sys.argv[0]))
OSError: [Errno 2] No such file or directory
Original exception was:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
from stevedore import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/__init__.py", line 1, in <module>
from .extension import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/extension.py", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2697, in <module>
_declare_state('object', working_set = WorkingSet())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 435, in __init__
self.add_entry(entry)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 450, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1723, in find_on_path
path_item = _normalize_cached(path_item)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1872, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1866, in normalize_path
return os.path.normcase(os.path.realpath(filename))
File "/usr/lib/python2.7/posixpath.py", line 375, in realpath
return abspath(filename)
File "/usr/lib/python2.7/posixpath.py", line 347, in abspath
cwd = os.getcwd()
OSError: [Errno 2] No such file or directory
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
from stevedore import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/__init__.py", line 1, in <module>
from .extension import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/extension.py", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2697, in <module>
_declare_state('object', working_set = WorkingSet())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 435, in __init__
self.add_entry(entry)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 450, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1723, in find_on_path
path_item = _normalize_cached(path_item)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1872, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1866, in normalize_path
return os.path.normcase(os.path.realpath(filename))
File "/usr/lib/python2.7/posixpath.py", line 375, in realpath
return abspath(filename)
File "/usr/lib/python2.7/posixpath.py", line 347, in abspath
cwd = os.getcwd()
OSError: [Errno 2] No such file or directory
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 70, in apport_excepthook
binary = os.path.realpath(os.path.join(os.getcwdu(), sys.argv[0]))
OSError: [Errno 2] No such file or directory
Original exception was:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
from stevedore import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/__init__.py", line 1, in <module>
from .extension import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/extension.py", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2697, in <module>
_declare_state('object', working_set = WorkingSet())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 435, in __init__
self.add_entry(entry)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 450, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1723, in find_on_path
path_item = _normalize_cached(path_item)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1872, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1866, in normalize_path
return os.path.normcase(os.path.realpath(filename))
File "/usr/lib/python2.7/posixpath.py", line 375, in realpath
return abspath(filename)
File "/usr/lib/python2.7/posixpath.py", line 347, in abspath
cwd = os.getcwd()
OSError: [Errno 2] No such file or directory
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
from stevedore import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/__init__.py", line 1, in <module>
from .extension import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/extension.py", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2697, in <module>
_declare_state('object', working_set = WorkingSet())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 435, in __init__
self.add_entry(entry)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 450, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1723, in find_on_path
path_item = _normalize_cached(path_item)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1872, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1866, in normalize_path
return os.path.normcase(os.path.realpath(filename))
File "/usr/lib/python2.7/posixpath.py", line 375, in realpath
return abspath(filename)
File "/usr/lib/python2.7/posixpath.py", line 347, in abspath
cwd = os.getcwd()
OSError: [Errno 2] No such file or directory
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 70, in apport_excepthook
binary = os.path.realpath(os.path.join(os.getcwdu(), sys.argv[0]))
OSError: [Errno 2] No such file or directory
Original exception was:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
from stevedore import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/__init__.py", line 1, in <module>
from .extension import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/extension.py", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2697, in <module>
_declare_state('object', working_set = WorkingSet())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 435, in __init__
self.add_entry(entry)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 450, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1723, in find_on_path
path_item = _normalize_cached(path_item)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1872, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1866, in normalize_path
return os.path.normcase(os.path.realpath(filename))
File "/usr/lib/python2.7/posixpath.py", line 375, in realpath
return abspath(filename)
File "/usr/lib/python2.7/posixpath.py", line 347, in abspath
cwd = os.getcwd()
OSError: [Errno 2] No such file or directory
You are trying to run virtualenv in a directory that has been removed. Recreate the directory, or use cd to go to an existing directory instead.

Categories