No Module Named neo4j in Travis-CI integrated with Python Django - django

I have built a small python application in Django framework, with Neo4j database hosted on Graphene db. I am integrating Travis-CI for continuous integration with the application on github, however, I am stuck on getting an error in Travis like: ImportError: No module named 'neo4j'
Below is my .travis.yml file:
language: python
python:
- "3.4"
- "2.7"
# command to install dependencies
install:
- pip install -q Django==$DJANGO_VERSION
- pip install py2neo
- pip install neo4django
- pip install -r requirements.txt
# command to run tests
script: python eb_django_app/neo4j/manage.py test
env:
- DJANGO_VERSION=1.8.3
branches:
only:
- master
manage.py :
import os
import sys
from py2neo import neo4j
from py2neo import ServiceRoot
graphenedb_url = os.environ.get("graphene db url", "http://localhost:7474/")
graph = ServiceRoot(graphenedb_url).graph
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "neo4j.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
The folder structure of python application is:
eb_django_app
|_ .travis.yml
|_ requirements.txt
|_ eb_django_app
|_python codebase
|_manage.py
|_neo4j
|_manage.py
|_tests.py
I am new to both Travis and Python. Am i missing something? Can someone please help me out with a solution to resolve this error, would really appreciate some immediate response?

Related

Django - how to import python module?

I would like to use Sendgrid's python library so I can use their Web API for sending email from Django. I installed the library and their example code says to from sendgrid import SendGridAPIClient. When I put this import into my app views.py, Django does not recognize this module - import sendgrid could not be resolved. I am running django inside docker, I did docker-compose down and then docker-compose up -d --build after pipenv install sendgrid. I then use docker-compose exec web python manage.py shell to enter the shell and I can import the module there. For some reason the import doesn't work in views though.
PS C:\Users\Doug\OneDrive\django\smartmark> pipenv install sendgrid
Installing sendgrid…
Adding sendgrid to Pipfile's [packages]…
Pipfile.lock (1e7343) out of date, updating to (4cf710)…
Locking [dev-packages] dependencies…
Success!
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (1e7343)!
Installing dependencies from Pipfile.lock (1e7343)…
================================ 37/37 - 00:00:02
PS C:\Users\Doug\OneDrive\django\smartmark>
Sendfile shows up in my Pipfile as sendgrid = "*".
Did you try to install sendgrid module in your virtual environment?
Just run:
pip install sendgrid

"Import flask from Flask" stops working after deactivating env

already searched database within stockoverflow -- there are no answers to this question!
"Import flask from Flask" stops working after deactivating env
installed python3:
"python3 --version" -->returns Python 3.7.4
installed virtualenv
"pip3 install virtualenv"
"virtualenv env"
"virtualenv --version" --> returns 16.7.4
activated virtual environment
"source env/b/activate" --> creates (env) note at terminal prompt correctly
installed flask in virtual environment
" pip3 install flask"
In the python shell, import flask does not return an error.
python program is:
...
from flask import Flask
app = Flask(__ name __)
#app.route('/')
def hello_world():
- return 'Hello, World!'
...
I get an error!
7. the error is: "unable to import flask"
ANY IDEAS ARE APPRECIATED. THANK YOU
I am using the following to run program:
export FLASK_APP=flask_blog.py
pip show flask --> returns: flask not found
pip3 show flask --> returns: flask version 1.1.1
pip doesn't find flask but pip3 does. What does that mean?
virtualenv venv creates a virtual environment that uses Python 2. Since it isn't using Python 3, pip3 install flask uses the system pip3, which lives outside the virtual environment. This will install Flask outside of the virtual environment.
It's unclear how you're invoking Python. If you're typing python3, if you're getting the system python3, which will be able to import Flask.
Regardless, to correct this, remove venv, and build it again using
virtualenv --python=python3 venv
and then either activate the virtual environment, or use one of the wrappers that that virtual environment provides for you. e.g.,
venv/bin/pip install Flask
then
FLASK_APP=app.py venv/bin/flask run

error running python manage.py on ubuntu

Please help, I am fairly new to django.
I am using virtualenv (which has django installed) I have used this command to create a new project
django-admin startproject projectname
and consequently used the code
cd projectname.
But when I run python manage.py
I get this error:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django'
this is how my manage.py file looks like:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "firstdjango.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Install virtual environment in your system
sudo apt-get install virtualenv
Create virtual environment
virtualenv envirnment_name
Activate virtual environment by following command
source envirnment_name/bin/activate
Install django in virtual environment
pip install django
And then run your django server
pyhton manage.py runserver
First, make sure that you are working on the virtualenv that you created using workon your_virtual_env.
Second, try the pip freeze > requirements.txt so you can check the installed packages. The file should have a structure like this:
Django == 1.10.2
SomePackage == 1.2.3
SomeOtherPackage == 1.2.3
You can verify that the Django package is installed this way.

cannot run django_quiz app. manage.py not found

I was trying to install the django_quiz app that was found on github.
https://github.com/tomwalker/django_quiz
And as you can see below, i've installed all requirements. but there's no manage.py. How do i start and run the project?
Things I did >
Cloned the repo with git clone https://github.com/tomwalker/django_quiz.git.
Run --> pip install -r requirements.txt.
Run --> python setup.py install
Added 'quiz', 'multichoice', 'true_false', 'essay' to INSTALLED_APPS setting.
Added url(r'^q/', include('quiz.urls')), to urls.py.
NB: I'm a beginner in Django. Please help me. I'm kind of stuck here.
Django Version : 1.6.5
Installed c:\python27\lib\site-packages\django_quiz_app-0.5.1-py2.7.egg
Processing dependencies for django-quiz-app==0.5.1
Searching for Pillow==2.5.0
Best match: Pillow 2.5.0
Adding Pillow 2.5.0 to easy-install.pth file
Using c:\python27\lib\site-packages
Searching for Django==1.6.5
Best match: Django 1.6.5
Adding Django 1.6.5 to easy-install.pth file
Using c:\python27\lib\site-packages
Searching for django-model-utils==2.0.3
Best match: django-model-utils 2.0.3
Adding django-model-utils 2.0.3 to easy-install.pth file
Using c:\python27\lib\site-packages
Finished processing dependencies for django-quiz-app==0.5.1
C:\Users\Vaisakhan\django_quiz>python manage.py runserver
python: can't open file 'manage.py': [Errno 2] No such file or directory
I think this repo misses some steps. I think the steps should be as follows:
pip install virtualenv (you can skip this step and the next one if you are sure that there will not be any dependency error.)
virtualenv ~/quiz_env
source ~/quiz_env/bin/activate
pip install Django==1.6.5
django-admin startproject quiz_project
navigate to quiz_project/quiz_project, edit setting files
navigate to quiz_project/ and copy all the apps directory ('quiz', 'multichoice',....etc) inside quiz_project along with requirement.txt file
pip install -r requirements.txt
python manage.py syncdb
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
Create a manage.py file and store it in the top folder of your file structure. Replace mysite with the folder holding your django quiz code.
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

Virtualenv and import six module erro in django 1.4

We install virtualenv inside every project in server:
virtualenv env
source env/bin/activate
pip install -r requirements.txt
But I have stil from django.utils.six import with_metaclass ImportError: No module named six
error in syncdb. I have this problem with django-modeltranslation.
Why I have this error? I could import six in python.
Django 1.4 is a very old version. django-modeltranslation clearly relies on a more recent version of Django.