AttributeError: 'ElasticSearch' object has no attribute 'bulk_index'" - django

When I try python manage.py rebuild_index, error occur:
self.conn.bulk_index(self.index_name, 'modelresult', prepped_docs, id_field=ID)
AttributeError: 'ElasticSearch' object has no attribute 'bulk_index'
I found the link https://github.com/toastdriven/pyelasticsearch/blob/master/pyelasticsearch.py#L424-469 with pyelasticsearch.py, and I dont know which edition it is. Anyway there is bulk_index in that code, buy my pyelasticsearch.py is not.
Anyone has the same experience? thanks for ur time.
Plus:
django-haystack 2.0.0.beta, pyelasticsearch 0.0.6

Django-haystack will NOT work with original pyelasticsearch. You need to use toastdrivens' fork instead: https://github.com/toastdriven/pyelasticsearch
If you use pip, just type:
pip uninstall pyelasticsearch
pip install git+git://github.com/toastdriven/pyelasticsearch.git

Related

AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'

I have been getting this error anytime i run my project with (runserver_plus --cert-file cert.crt)...I already installed the django extensions and pyOpenSSL
I tried running without the (--cert-file cert.crt), that one seems to work fine buh doesnt provide me with what I am looking for .
You can try to downgrade the cryptography lib:
pip install --force-reinstall "cryptography==38.0.4"
Seems to be a temporary bug, fixed, but pending to release: https://github.com/aws/aws-sam-cli/issues/4527#issuecomment-1368871248

Language Translation using Python

I used to use GoogleTrans but this has stopped working with this error
AttributeError: 'NoneType' object has no attribute 'group'
I then found this article googletrans stopped working with error 'NoneType' object has no attribute 'group'
I then tried to use the version by running pip install googletrans==3.1.0a0
However, as I am using Python 2.7 it does not seem to work. I am writing an Agent for Plex and therefore, I am tied in with Python 2.7..
Does anyone know of any translation libraries that still work with Python 2.7??
Have you tried installing google-cloud-translate==2.0.1?
See here under "Deprecated Python Versions"
https://pypi.org/project/google-cloud-translate/
I ended up using this library - free to use and no need to register for a licence or key....
https://pypi.org/project/doodle-translate/
to install
pip install doodle-translate

Module object has no attribute SQLStorageAdapter

While running django chatterbot app, i encounter an error
module' object has no attribute 'SQLStorageAdapter'
I define chatbot the following way in my view.
chatbot = ChatBot(
"SQLMemoryTerminal",
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
"chatterbot.logic.MathematicalEvaluation",
"chatterbot.logic.TimeLogicAdapter",
"chatterbot.logic.BestMatch"
],
input_adapter="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter",
)
Can anybody tell me why I am getting this error? Should I need any extra library or something like that? Thanks.
I think you were using very old version of chatterbot, you could try to upgrade to latest version by using.
pip install --upgrade chatterbot
Instead SQLStorageAdapter I recommended to use Mongo-DB as your storage adapter.
For more information fallow this link http://chatterbot.readthedocs.io/en/stable/storage/index.html#mongodb-storage-adapter

python: weird "AttributeError: 'NoneType' object has no attribute 'FrontEndTestingStart'"

utils/frontend/urls.py
from utils.frontend import views
#more stuff
views.FrontEndTestingStart.as_view()
utils/frontend/views.py
class FrontEndTestingStart(APIView):
python reports
AttributeError: 'NoneType' object has no attribute 'FrontEndTestingStart'
As if views.py would return None when importing.
Why is that?
I have a __init__.py in the directory
The object instance in FrontEndTestingStart is returning None. Hence the issue. For further clarification see these answers - https://stackoverflow.com/a/8949265/5911972 and https://stackoverflow.com/a/8949272/5911972
Here's what got my problem fixed - but I don't know why.
Thanks to #2ps and #rohittk239, of cournse they are both right, but I couldn't find out WHAT exactly was causing that behaviour. Thanks both for trying to help.
I am trying to help a client run a software they bought. It's built on django 1.6.2 (yes I know it's dinosaur).
It had been configured on a long list of dependencies in requirements.txt. Most of them were fixed at a specific version with ==, but some were not, and were on >=. When I then ran pip install -r requirements, this of course would install newer versions than the ones specified everywhere where there was a >= dependency.
Fixing the requirements.txt for all dependencies to == fixed the problem. Looks like some dependency in a later version would create a conflict.

Using Point Cloud Library in Python

Hello I am trying to use Point Cloud Library in Python and as I am new to this C++ library and Python I am following the tutorial on http://strawlab.github.io/python-pcl/#pcl.PointCloud
However whenever I try to import pcl and define a module such as pcl.PointCloud() I get the following error;
AttributeError: 'module' object has no attribute 'PointCloud'
I have used sys.path.append to point to the correct directory where the PCL files have been installed as they are not in site packages. It says on the above link that the C++ code has already got Python bindings but I am unsure exactly what files I am trying to call in Python. Does anybody know how to overcome this error and load these modules?
Thanks,
Andrew
Try this,
sudo add-apt-repository ppa:sweptlaser/python3-pcl
sudo apt update
sudo apt install python3-pcl
After you've done that then you should be able to run:
python3 -c 'import pcl'
and it will return with no error (as opposed to ModuleNotFoundError: No module named 'pcl').
Tested on:
Ubuntu 18.04 LTS
Python 3.6.9
Reference: https://askubuntu.com/a/1170661/922137
Try skipping the parentheses:
from pcl import PointCloud
And then create an instance of PointCloud, for example, p:
p = PointCloud()
Hope it helps!
Looks like you need PCL 1.5.1 and cython 0.16 according to this page: http://strawlab.github.io/python-pcl/
"""https://blog.pollithy.com/python/numpy/pointcloud/tutorial-pypcd"""
python3.6 -m pip install --user git+https://github.com/DanielPollithy/pypcd.git