How to run pip installed elasticsearch? - python

I'm trying to use Django + Haystack + Elasticsearch.
So I installed Elasticsearch 2.4 with pip becouse Django gave me errors about that it can't import Elasticsearch. Now it can and I can run ./manage.py rebuild_index in my Django project and it gives this output:
Indexing 23 journal entrys
GET /haystack/_mapping [status:404 request:0.006s]
but only if I somehove run elasticsearch. So I installed elsasticsearch2 from AUR packages as well and run that. But as I suspected when I try to get all documents by running: curl -X GET "localhost:9200/_cat/indices?v" which returns:
health status index pri rep docs.count docs.deleted store.size pri.store.size
yellow open haystack 5 1 0 0 795b 795b
If I understand correctly it is empty.
I went where pip installs packages(/usr/lib/python3.6/site-packages) and found two folders related to Elasticsearch:
elasticsearch
├── client
│   ├── cat.py
│   ├── cluster.py
│   ├── indices.py
│   ├── ingest.py
│   ├── __init__.py
│   ├── nodes.py
│   ├── __pycache__
│   │   ├── cat.cpython-36.pyc
│   │   ├── cluster.cpython-36.pyc
│   │   ├── indices.cpython-36.pyc
│   │   ├── ingest.cpython-36.pyc
│   │   ├── __init__.cpython-36.pyc
│   │   ├── nodes.cpython-36.pyc
│   │   ├── snapshot.cpython-36.pyc
│   │   ├── tasks.cpython-36.pyc
│   │   └── utils.cpython-36.pyc
│   ├── snapshot.py
│   ├── tasks.py
│   └── utils.py
├── compat.py
├── connection
│   ├── base.py
│   ├── http_requests.py
│   ├── http_urllib3.py
│   ├── __init__.py
│   ├── pooling.py
│   └── __pycache__
│   ├── base.cpython-36.pyc
│   ├── http_requests.cpython-36.pyc
│   ├── http_urllib3.cpython-36.pyc
│   ├── __init__.cpython-36.pyc
│   └── pooling.cpython-36.pyc
├── connection_pool.py
├── exceptions.py
├── helpers
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-36.pyc
│   │   └── test.cpython-36.pyc
│   └── test.py
├── __init__.py
├── __pycache__
│   ├── compat.cpython-36.pyc
│   ├── connection_pool.cpython-36.pyc
│   ├── exceptions.cpython-36.pyc
│   ├── __init__.cpython-36.pyc
│   ├── serializer.cpython-36.pyc
│   └── transport.cpython-36.pyc
├── serializer.py
└── transport.py
elasticsearch-2.4.1.dist-info
├── DESCRIPTION.rst
├── INSTALLER
├── METADATA
├── metadata.json
├── pbr.json
├── RECORD
├── top_level.txt
└── WHEEL
I don't see a start_elasticsearch.sh or bin/elasticsearch so how can I start it?

Related

NotSupportedError at / deterministic=True requires SQLite 3.8.3 or higher

I am trying to deploy a Django application using the default SQLite database to Elastic Beanstalk. The application works fine locally, however, on server, I get the error as :
Any idea what's wrong? Can we not deploy SQLite app on AWS EBS?
Here is my project structure that is getting deployed
├── .ebextensions
│   ├── django.config
├── app
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── __init__.py
│   ├── models.py
│   ├── static
│   │   └── app
│   │   ├── app.js
│   │   ├── logo.svg
│   │   └── style.css
│   ├── templates
│   │   └── app
│   │   ├── hello.html
│   │   ├── index.html
│   │   └── job_detail.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── db.sqlite3
├── env
│   ├── All Virtual env related files
├── images
│   ├── Photo_on_5-9-14_at_2.31_PM.jpg
│   ├── Photo_on_5-9-14_at_2.32_PM.jpg
│   └── Photo_on_5-9-14_at_2.32_PM_v4McLzE.jpg
├── myproject-test
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── manage.py
├── requirements.txt
├── staticfiles
│   |-- All static files collected using collectstatic
│   ├── app
│   │   ├── app.js
│   │   ├── logo.svg
│   │   └── style.css
│   └── subscribe
│   ├── email-icon.png
│   ├── main.css
│   └── main.js
├── subscribe
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── form.py
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── 0002_subscribe_option_alter_subscribe_email_and_more.py
│   │   ├── 0003_alter_subscribe_option.py
│   ├── models.py
│   ├── static
│   │   └── subscribe
│   │   ├── email-icon.png
│   │   ├── main.css
│   │   └── main.js
│   ├── templates
│   │   └── subscribe
│   │   ├── subscribe.html
│   │   └── thank_you.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── templates
│   └── base.html
├── upload
│   └── images
│   ├── Photo_on_5-9-14_at_2.31_PM.jpg
│   └── Photo_on_5-9-14_at_2.31_PM_3.jpg
└── uploads
├── __init__.py
├── admin.py
├── apps.py
├── forms.py
├── images
│   └── Photo_on_5-9-14_at_2.31_PM_3.jpg
├── migrations
│   ├── 0001_initial.py
│   ├── 0002_uploadfile.py
│   ├── 0003_alter_uploadfile_file.py
│   ├── __init__.py
├── models.py
├── templates
│   └── uploads
│   ├── add_file.html
│   └── add_image.html
├── tests.py
├── urls.py
└── views.py
Deployment process:
Zip all the necessary files
Create AWS EBS application with Python
Add environment variables
Create app and access URL
Please help.

Unable to import functions in Python

Trying to resolve some packages >= Python 3.3
├── dags
│   ├── common
│   │   ├── aws.py
│   │   ├── conf.py
│   │   ├── constants.py
│   │   ├── metamorph.py
│   │   └── sensor.py
│   ├── global.cfg
│   ├── dag_1
│   │   ├── README.md
│   │   ├── configuration
│   │   │   └── config.json
│   │   ├── dag
│   │   │   ├──
│   │   │   └── test.py
in test.py I'm trying to import things from common, but unable to get it resolved. I've print things on the sys.path but not seeing any conf in there. What am I missing?

Cant find module Django while deploying on Elastic Beanstalk

I am trying to deploy the backend of this repository https://github.com/LaunchKit/LaunchKit on Elastic Beanstalk.
I am very new to Django and I successfully did those two tutorials explaining how to deploy Django on Elastic Beanstalk:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
https://realpython.com/blog/python/deploying-a-django-app-and-postgresql-to-aws-elastic-beanstalk/
I keep having the message ImportError: No module named 'django'
Here is a part of my file structure located into the folder "firekit"
├── LICENSE
├── README.md
├── backend
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── celery_app.py
│   ├── celery_app.pyc
│   ├── lk
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── logic
│   │   ├── migrations
│   │   ├── models
│   │   ├── oauth_middleware.py
│   │   ├── oauth_middleware.pyc
│   │   ├── tasks.py
│   │   ├── templates
│   │   ├── templatetags
│   │   ├── urls.py
│   │   ├── urls.pyc
│   │   └── views
│   ├── manage.py
│   ├── middleware.py
│   ├── middleware.pyc
│   ├── requirements.txt
│   ├── settings.py
│   ├── settings.pyc
│   ├── site_media
│   │   └── images -> ../../skit/lk/__static__/images
│   ├── templates
│   │   └── robots.txt
│   ├── urls.py
│   ├── urls.pyc
│   ├── util
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── bitwise.py
│   │   ├── bitwise.pyc
│   │   ├── cryptoid.py
│   │   ├── cryptoid.pyc
│   │   ├── dnsutil.py
│   │   ├── dnsutil.pyc
│   │   ├── enum.py
│   │   ├── enum.pyc
│   │   ├── environment_loader.py
│   │   ├── hstore_field.py
│   │   ├── hstore_field.pyc
│   │   ├── html_to_text.py
│   │   ├── html_to_text.pyc
│   │   ├── lkforms.py
│   │   ├── lkforms.pyc
│   │   ├── multipart.py
│   │   ├── text.py
│   │   ├── text.pyc
│   │   ├── urlutil.py
│   │   ├── urlutil.pyc
│   │   ├── urlviews.py
│   │   └── urlviews.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
├── devproxy.go
├── frontend_firekit
│   ├── JSXTransformer.js
│   ├── app.js
│   ├── lk
│   │   ├── __static__
│   │   ├── library
│   │   ├── public
│   │   ├── public_hosted
│   │   └── third_party
│   ├── node_modules
│   │   ├── accepts
│   │   ├── acorn
│   │   ├── align-text
│   │   ├── amdefine
│   │   ├── ansi-regex
│   │   ├── ansi-styles
│   │   ├── asn1
│   │   ├── assert-plus
│   │   ├── async
│   │   ├── aws-sign2
│   │   ├── aws4
│   │   ├── bcrypt-pbkdf
│   │   ├── bl
│   │   ├── body-parser
│   │   ├── boom
│   │   ├── bytes
│   │   ├── camelcase
│   │   ├── caseless
│   │   ├── center-align
│   │   ├── chalk
│   │   ├── cliui
│   │   ├── combined-stream
│   │   ├── commander
│   │   ├── compressible
│   │   ├── compression
│   │   ├── connect
│   │   ├── content-type
│   │   ├── cookies
│   │   ├── core-util-is
│   │   ├── cryptiles
│   │   ├── dashdash
│   │   ├── debug
│   │   ├── decamelize
│   │   ├── delayed-stream
│   │   ├── depd
│   │   ├── destroy
│   │   ├── ecc-jsbn
│   │   ├── ee-first
│   │   ├── escape-html
│   │   ├── escape-string-regexp
│   │   ├── etag
│   │   ├── eventemitter3
│   │   ├── extend
│   │   ├── extsprintf
│   │   ├── finalhandler
│   │   ├── forever-agent
│   │   ├── form-data
│   │   ├── fresh
│   │   ├── generate-function
│   │   ├── generate-object-property
│   │   ├── getpass
│   │   ├── graceful-readlink
│   │   ├── handlebars
│   │   ├── har-validator
│   │   ├── has-ansi
│   │   ├── hawk
│   │   ├── hoek
│   │   ├── http-errors
│   │   ├── http-proxy
│   │   ├── http-signature
│   │   ├── iconv-lite
│   │   ├── inherits
│   │   ├── is-buffer
│   │   ├── is-my-json-valid
│   │   ├── is-property
│   │   ├── is-typedarray
│   │   ├── isarray
│   │   ├── isstream
│   │   ├── jodid25519
│   │   ├── jsbn
│   │   ├── json-schema
│   │   ├── json-stringify-safe
│   │   ├── jsonpointer
│   │   ├── jsprim
│   │   ├── keygrip
│   │   ├── kind-of
│   │   ├── lazy-cache
│   │   ├── lodash
│   │   ├── longest
│   │   ├── media-typer
│   │   ├── mime
│   │   ├── mime-db
│   │   ├── mime-types
│   │   ├── minimist
│   │   ├── ms
│   │   ├── negotiator
│   │   ├── node-uuid
│   │   ├── oauth-sign
│   │   ├── on-finished
│   │   ├── on-headers
│   │   ├── optimist
│   │   ├── parseurl
│   │   ├── pinkie
│   │   ├── pinkie-promise
│   │   ├── process-nextick-args
│   │   ├── qs
│   │   ├── range-parser
│   │   ├── raw-body
│   │   ├── readable-stream
│   │   ├── repeat-string
│   │   ├── request
│   │   ├── requires-port
│   │   ├── right-align
│   │   ├── send
│   │   ├── setprototypeof
│   │   ├── skit
│   │   ├── sntp
│   │   ├── source-map
│   │   ├── sshpk
│   │   ├── statuses
│   │   ├── string_decoder
│   │   ├── stringstream
│   │   ├── strip-ansi
│   │   ├── supports-color
│   │   ├── tough-cookie
│   │   ├── tunnel-agent
│   │   ├── tweetnacl
│   │   ├── type-is
│   │   ├── uglify-js
│   │   ├── uglify-to-browserify
│   │   ├── unpipe
│   │   ├── util-deprecate
│   │   ├── utils-merge
│   │   ├── vary
│   │   ├── verror
│   │   ├── window-size
│   │   ├── wordwrap
│   │   ├── xtend
│   │   └── yargs
│   ├── package.json
│   └── settings.js
├── gae
│   ├── app.yaml
│   ├── favicon.ico
│   ├── index.yaml
│   ├── launchkit_images
│   │   ├── __init__.py
│   │   ├── basehandler.py
│   │   ├── blobinternalhandlers.py
│   │   ├── blobpublichandlers.py
│   │   ├── models.py
│   │   └── util.py
│   ├── main.py
│   └── third_party
│   ├── __init__.py
│   └── poster
├── manage.py
├── requirements.txt
├── review_ingester.py
└── venv
├── bin
│   ├── activate
│   ├── activate.csh
│   ├── activate.fish
│   ├── activate_this.py
│   ├── easy_install
│   ├── easy_install-2.7
│   ├── pip
│   ├── pip2
│   ├── pip2.7
│   ├── python
│   ├── python-config
│   ├── python2 -> python
│   ├── python2.7 -> python
│   └── wheel
├── include
│   └── python2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
├── lib
│   └── python2.7
└── pip-selfcheck.json
02_python.config
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "settings"
"PYTHONPATH": "/opt/python/current/app:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: backend/wsgi.py
backend/wsgi.py
import os
import sys
sys.path.insert(0, '/opt/python/current/app')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Do you have any ideas of why I keep having the "No module named 'django'" error message? Thanks a lot for your help!
EDIT
requirements.txt
boto==2.38.0
celery[redis]==3.1.17
cssutils==1.0.1
django-bitfield==1.7.1
Django==1.7.3
djorm-pgarray==1.2.0
dnspython==1.12.0
fabric==1.10.1
hiredis==0.1.5
Pillow==3.0.0
premailer==1.3.0
psycopg2==2.5.4
pycrypto==2.6.1
pylint==0.28.0
python-memcached==1.53
redis==2.10.3
requests==2.5.3
sqlalchemy==0.9.8
tweepy==3.3.0
ua-parser==0.3.6
When i run pip freeze locally it says:
amqp==1.4.9
ansible==2.1.1.0
anyjson==0.3.3
awsebcli==3.7.8
beautifulsoup4==4.1.3
billiard==3.3.0.23
bleach==1.4
blessed==1.9.5
boto==2.38.0
botocore==1.4.61
Cartridge==0.9.4
celery==3.1.17
cement==2.8.2
cffi==1.8.3
colorama==0.3.7
cryptography==1.5.1
cssselect==0.9.1
cssutils==1.0.1
Django==1.7.3
django-bitfield==1.7.1
djorm-pgarray==1.2
dnspython==1.12.0
docker-py==1.7.2
dockerpty==0.4.1
docopt==0.6.2
docutils==0.12
enum34==1.1.6
Fabric==1.10.1
filebrowser-safe==0.3.5
future==0.9.0
gnureadline==6.3.3
grappelli-safe==0.3.12
hiredis==0.1.5
html5lib==0.999
idna==2.1
image==1.2
ipaddress==1.0.17
ipython==2.0.0
Jinja2==2.8
jmespath==0.9.0
kombu==3.0.37
logilab-astng==0.24.3
logilab-common==1.2.2
lxml==3.3.0
MarkupSafe==0.23
matplotlib==1.4.0
mercurial==3.7.1+20160203
Mezzanine==3.1.8
mock==1.0.1
MySQL-python==1.2.5
nose==1.3.4
numpy==1.9.0
oauthlib==0.6.3
pandas==0.14.1
paramiko==2.0.2
pathspec==0.3.4
PIL==1.1.7
Pillow==3.0.0
premailer==1.3.0
psycopg2==2.5.4
pyasn1==0.1.9
pycparser==2.14
pycrypto==2.6.1
pylint==0.28.0
pymongo==2.7
PyMySQL==0.6.2
pyparsing==2.0.2
PyPDF2==1.22
python-dateutil==2.5.3
python-magic==0.4.12
python-memcached==1.53
pytz==2014.4
PyYAML==3.12
queuelib==1.1.1
redis==2.10.3
reportlab==3.1.8
requests==2.9.1
requests-oauthlib==0.4.1
s3cmd==1.6.1
Scrapy==0.22.0
semantic-version==2.5.0
six==1.10.0
SQLAlchemy==0.9.8
texttable==0.8.4
tweepy==3.3.0
tzlocal==1.0
ua-parser==0.3.6
vboxapi==1.0
virtualenv==15.0.3
w3lib==1.5
wcwidth==0.1.7
websocket-client==0.37.0
xhtml2pdf==0.0.6
I tried with both configurations and I keep having the same error.
EDIT2
Still having the same error
I did ssh in EB.
Find site-packages.
Added all path found to wsgi.py
/opt/python/run/baselinenv/lib64/python3.4/site-packages
/opt/python/run/baselinenv/lib/python3.4/site-packages
/opt/python/run/venv/lib64/python3.4/site-packages
/opt/python/run/venv/lib/python3.4/site-packages
/usr/lib64/python2.7/site-packages
/usr/lib/python2.7/site-packages
/usr/local/lib64/python3.4/site-packages
/usr/local/lib64/python2.7/site-packages
/usr/local/lib/python3.4/site-packages
/usr/local/lib/python2.7/site-packages
This is super old but I was going through the same thing. I found out that my application was not updating with the changes i was deploying, the reason was because I was using git in my folder and I had not committed those changes, so the deployment kept deploying the previously committed code.
Just in case someone is going through the same rabbit hole I went through today.

Django template not found in main project directory error

I am getting a 'template not found' error, although I've set up a correct template hierarchy (or so I thought)
.
├── manage.py
├── twinja
│   ├── admin.py
│   ├── admin.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── migrations
│   │   ├── __init__.py
│   │   └── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── tests.py
│   └── views.py
└── twinjasite
├── __init__.py
├── __init__.pyc
├── settings.py
├── settings.py~
├── settings.pyc
├── static
│   └── twinja
│   ├── fonts
│   │   └── bootstrap
│   │   ├── glyphicons-halflings-regular.eot
│   │   ├── glyphicons-halflings-regular.svg
│   │   ├── glyphicons-halflings-regular.ttf
│   │   ├── glyphicons-halflings-regular.woff
│   │   └── glyphicons-halflings-regular.woff2
│   ├── images
│   ├── javascripts
│   │   ├── bootstrap
│   │   │   ├── affix.js
│   │   │   ├── alert.js
│   │   │   ├── button.js
│   │   │   ├── carousel.js
│   │   │   ├── collapse.js
│   │   │   ├── dropdown.js
│   │   │   ├── modal.js
│   │   │   ├── popover.js
│   │   │   ├── scrollspy.js
│   │   │   ├── tab.js
│   │   │   ├── tooltip.js
│   │   │   └── transition.js
│   │   ├── bootstrap.js
│   │   ├── bootstrap.min.js
│   │   └── bootstrap-sprockets.js
│   └── stylesheets
│   ├── framework.css
│   └── styles.css
├── templates
│   └── twinja
│   ├── base.html
│   └── menu.html
├── urls.py
├── urls.py~
├── urls.pyc
├── views.py
├── views.py~
├── views.pyc
├── wsgi.py
└── wsgi.pyc
At first I set up templates/base but that did not work. So I made it as you see here: templates/twinja/base
Ideally I'm setting up the MAIN template files which are independent of apps, which I thought was meant to go in the main folder (where settings.py is) but perhaps I am mistake.
Yes, I have 'twinja' set up in installed apps as well.
What appears to be wrong here?
TemplateDoesNotExist at /
twinja/base.html
If your template is independent of apps, it shouldn't be in your app folder - namespace it accordingly.
How do you load your template? Did you setup your templates/staticfolders in your settings.py?
Updated.
For the fresh project you need to configure your settings.py file. Read here, ask away if you still have a question.
Updated.
After you get familiar with static files and how to manage those, spend some time here.

Python - how do i load my custom class methods from a root directory?

How do import my class from a specific directory (in my case root directory i want to keep it).
So, i have following directory map, now i need to load the class parsePresets from myglobal.py file, which is located in root directory: /var/tmp/mypython directory.
but, i want to import that from class/methods from my new module: /var/tmp/mypython/media/test.py with:
from myglobal import parsePresets
but i am getting:
from myglobal import parsePresets
ImportError: No module named myglobal
i also have init.py in root directory and in the media directory.
$ cd /var/tmp/mypython; tree
.
├── arduino
│   ├── arduino.diest.c
│   ├── arduino.gent.c
│   ├── arduino.lalouvier.c
│   ├── arduino.makenoise.c
│   ├── arduino.servo.c
│   ├── arduino.string.c
│   ├── arduino.tcpserver.c
│   ├── arduino.tcpserver.c~
│   ├── arduino.test.sh
├── bash
│   ├── all.sh
│   ├── alsa-info.sh
│   ├── asound.conf
│   ├── autoreboot.sh
│   ├── diskfix.sh
│   ├── kernelfix.sh
│   ├── update.sh
│   └── usbformat.sh
├── chrome.py
├── download.py
├── download.sh
├── gui.py
├── image
│   ├── a.png
│   ├── b.gif
│   ├── cross_new.png
│   ├── e150
│   │   ├── 1.png
│   │   ├── de.png
│   │   ├── en.png
│   │   ├── __init__.py
│   │   └── nl.png
│   ├── __init__.py
│   ├── logo.png
│   ├── menu.jpg
│   └── slider_btn.png
├── __init__.py
├── INSTALL
├── ip.py
├── loading.py
├── logout.py
├── media
│   ├── __init__.py
│   ├── test.py
├── menu.py
├── myglass.py
├── myglass.pyc
├── myglobal.py
├── myglobal.pyc
├── rightclick.py
├── runme.sh
├── server.py
├── server.pyc
├── src.nja
├── test
│   ├── Button.py
│   ├── json.py
│   ├── json.pyc
│   ├── keyboard.py
│   ├── loop.sh
│   ├── mytimer.py
│   ├── qtclick.py
│   ├── qtmouse.py
│   ├── qt.py
│   ├── qtwindows7.py
│   ├── shape.py
│   ├── skeleton.py
│   ├── slider.py
│   ├── testpreview.py
│   ├── test.py
│   ├── Text.py
│   ├── transparent.py
│   ├── transparentwindow.py
│   └── Vscale.py
├── test.py
├── unavailable.py
├── upload.sh
└── internet
├── backup
├── protocol.txt
└── server.py
You can add sys.path.append(/var/tmp/mypython/media/) to your script.
EDIT:
$ cat >> /var/tmp/mypython/stackoverflow.py <<\EOF
import sys
sys.path.append("/var/tmp/mypython/")
from myglobal import parsePresets
EOF
$ python /var/tmp/mypython/stackoverflow.py
or with NINJA-IDE
Running: /var/tmp/mypython/media/stackoverflow.py (Wed Dec 11 13:37:25 2013)
Execution Successful!
Use relative imports
from ..myglobal import parsePresets
The extra periods . take you "out" a level in your hierarchy.

Categories