aerospike-client-python icon indicating copy to clipboard operation
aerospike-client-python copied to clipboard

python3: ImportError while import aerospike.exception

Open jarda-manana opened this issue 9 years ago • 9 comments

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.

jarda-manana avatar Mar 03 '16 07:03 jarda-manana

What's pypi3? Do you mean the PyPy runtime, or the module repo PyPI?

rbotzer avatar Mar 03 '16 07:03 rbotzer

Sorry, typpo. I meant: "installed by pip3". To be clear - whole command is pip3 install aerospike, where pip3 is executable from package python3-pip.

jarda-manana avatar Mar 03 '16 07:03 jarda-manana

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?

jboone100 avatar Mar 16 '16 17:03 jboone100

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

jarda-manana avatar Mar 17 '16 06:03 jarda-manana

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.

jboone100 avatar Mar 17 '16 14:03 jboone100

Yes, this solution works. I have used:

import aerospike
...
except aerospike.exception.AerospikeError as e:
...

that works without problems too. Thanks

jarda-manana avatar Mar 18 '16 06:03 jarda-manana

Closing this as the import issue has been resolved.

jboone100 avatar Sep 07 '16 22:09 jboone100

Please update the docs https://www.aerospike.com/apidocs/python/exception.html

nikegp avatar Feb 21 '17 11:02 nikegp

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

juliannguyen4 avatar Feb 24 '23 20:02 juliannguyen4