aerospike-client-python
aerospike-client-python copied to clipboard
python3: ImportError while import aerospike.exception
Client version 2.0.1 installed by pypi3 on debian 8.2 or ubuntu 14.04:
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
from aerospike.exception import AerospikeError
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'aerospike.exception'; 'aerospike' is not a package
This error doesn't occurred in python2.
What's pypi3? Do you mean the PyPy runtime, or the module repo PyPI?
Sorry, typpo. I meant: "installed by pip3". To be clear - whole command is pip3 install aerospike, where pip3 is executable from package python3-pip.
I grabbed a debian8 vagrant image and executed these steps:
$ sudo apt-get update
$ sudo apt-get install libssl-dev
$ sudo apt-get install openssl
$ cd /opt
$ sudo wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz
$ sudo tar xzf Python-3.4.3.tgz
$ cd Python-3.4.3/
$ sudo ./configure
$ sudo make
$ sudo make install
$ sudo pip3 install aerospike
$ python3
From there I can import the aerospike module.
Are those the steps you followed when installing Python/Pip and then the aerospike module?
No, python3 and python3-pip was installed via apt:
$ apt-get install python3
$ apt-get install python3-pip
$ pip3 install aerospike
To be clear: import aerospike works, but from aerospike.exception import AerospikeError doesn't.
However - I'm trying this on fresh debian 8.3 right now and I'm not able to to install aerospike via pip3 install aerospike - getting UnicodeEncodeError Exception. Debug log from pip is attached.
pip.log.gz
For the import statement, try this:
from aerospike import exception as e
...
except e.AerospikeError as exception
I'll have a look at the install log.
Yes, this solution works. I have used:
import aerospike
...
except aerospike.exception.AerospikeError as e:
...
that works without problems too. Thanks
Closing this as the import issue has been resolved.
Please update the docs https://www.aerospike.com/apidocs/python/exception.html
This issue still occurs in 10.0.1 if you run:
>>> from aerospike.exception import AerospikeError
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'aerospike.exception'; 'aerospike' is not a package