No module named 'chartit'; - django

I am trying to use chartit in django and in its documentation it says add chartit to INSTALLED APPS in "settings.py".
When I try to do that, it gives this error:
ImportError: No module named 'chartit'
How do I import it?
Thank you.
PS-Sorry, it's a silly question.

You missed installing it with pip install django_chartit.
EDIT:
The error you described is thrown by python if a module is not found in the running environment. You need to make sure, that you've installed it in the environment that is used by your django.
Try typing pip list in the shell you usually use to kick your django with python manage.py runserver to figure out what is installed there.
If your django lives inside of a IDE like PyCharm - you need to check the project settings there for the environment used to launch django.
As you don't use virtualenv (which is highly recommended) you install your modules system wide. If you are on linux there might be python3 and python (which is python 2). If your pip belongs to python2 and you have installed django in python3 or vice versa this might be the issue.

from chartit import DataPool, Chart

Related

cant import flask-wtf after install

I have been looking around for an answer to this question, but everywhere I see the advice of running a pip install flask-wtf in the virtual environment. The requirements have already been satisfied in mine, but for some reason I am getting a missing module error. I am working on a school project building a website using flask and would really appreciate the help. My import is:
from flask_wtf import Form`
When I try to run the install command I get a message that says the requirement is already satisfied, as shown in this image.
Based on the screenshot, your flask-wtf and friends are installed outside virtualenvs, in the system site-packages directory.
It'd be a good idea to uninstall those from the global site-packages directory (python3 -m pip uninstall flask-wtf wtforms flask jinja2 click werkzeug markupsafe itsdangerous), create and activate a virtualenv (python3 -m venv my_venv and ./my_venv/bin/activate), then reinstall the dependencies within the virtualenv.

ImportError: No module named 'django' despite having it installed running apache2 server

I know that many have posted similar question however I tried most solution without success.
I'm trying to host a webpage with apache2 and django in python3.
In the error log I found ImportError: No module named 'django' when accessing the wsgi.pyfile, where I also added import sys, sys.version to confirm which python version is used and from the error log I can see that I'm running following python version 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609].
When I run python3.5 I see that I uses the same python version and here I can run import django without any error!
EDIT: I checked django.__file__and saw that it was located in /home/USERNAME/.local/lib/python3.5/site-packages/django/init.py and that path /home/USERNAME/.local/lib/python3.5/site-packages wasn't in the sys.path that tried to run django. But adding it with sys.path.append(path) didn't help :(
Any thoughts what I might have messed up?
If you have Setup the whole configuration in VirtualEnv then , i suggest you to activate it by,
source /location to /env/bin activate
pip3 install django=version_id
or pip install django=version id
if you want to pass version id then its good or it will install the latest django from your repo.
Now test Django Version there.
Hope you will no get the error.
Location - means the path where env will be located in project directory, if you have followed the standard installation process of django or else you don't need, and version id- vesion of django framework.
I finally understood how to solve it! first I had to run pip3 uninstall django then run sudo pip3 install django.

Path issue Pip (Psycopg2) inside VirtualEnv

When using Pip (6.0.8) to install Django (1.9) and Psycopg2 (2.6.1), Django got installed in the env/lib/python2.7/site-packages folder and Psycopg2 in the env/lib64/python2.7/site-packages folder.
When I'm using command line (eg python manage.py migrate) or >>> import psycopg2, this all works fine. But when Mod_WSGI is running the application it complains that there is no module Psycopg2.
I'm able to work around this issue by adding the lib64 as a python path in my Apache conf file, but I'm pretty sure this is not the best possible way.
Any suggestions for a better solution?
Btw: I noticed by the way that Pip 7.1.2 is installing Django in Lib64 as well iso Lib.
Yes, there is with the use of --install-option. Have a look at the docs

Is there a way to install Django 1.2 and 1.3 side by side?

I need to use Django 1.2 for one of my projects.
I also already have several projects running on Django 1.3 on the same server, and I need to keep them running.
Is there a way to only use 1.2 for a specific project?
Both sites run on Apache via mod_wsgi.
Consider installing Django inside a virtualenv. This will make the installation of python modules, including Django, completely independent of the rest of the system. This way, if you have multiple virtualenvs, you can have as many versions of Django installed (one per env).
To use a virtualenv, you shold edit your index.wsgi and add the following two lines before any other line that imports or references Django:
activate_this = '/path/to/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
This is assuming that you are not using different version of the python interpreter itself, which is possible using virtualenv, but would make things quite a bit more complicated.
Yes. Django is just a regular Python module living in your site-packages. So when you import django.something, the way Python decides which version to load is by walking down the Python path (import sys; print sys.path) in order and looking for a directory called django (with something.py or something/_init_.py inside). It loads the first one it finds. So the quickest method is to modify this Python path before starting your project, which can be conveniently done with an environment variable named PYTHONPATH.
So for your Django 1.2 project, install Django 1.2 in site-packages/django-1.2 and then:
# run Django 1.2 for old app that I don't have time to update
cd ~gaearon/src/old-django-project
env PYTHONPATH=/Library/Python/2.6/site-packages/django-1.2 ./manage.py runserver
For all other (Django 1.3) projects, simply install Django as normal, which makes it the default:
# all other projects use the system default Django 1.3
cd ~gaearon/src/current-django-project
./manage.py runserver
For production servers you won't use runserver, but the PYTHONPATH will work wherever you invoke Python (i.e. flup, or manage.py runfcgi). If invoked from mod_python there is an Apache configuration directive to modify the Python path (see mod_python documentation).
Or you could use virtualenv.
When I need to do stuff like this I have found that virtualenv combined with virtualenvwrapper helps a lot.
> mkvirtualenv django1.2
> cd django-1.2-dist-dir
> python setup.py install
> mkvirtualenv django1.3
> cd django-1.3-dist-dir
> python setup.py install
Now both Django versions are installed in their own virtual environments. To use a specific one do:
> workon django1.2
or
> workon django1.3

importerror: No module named django

I installed python 2.6 alongside my mac's 2.5.2 version. As soon as I did, python2.6 manage.py runserver failed because it couldn't find django.core.management.
From a shell, import django returns importerror: No module named django.
Why?
Did you reinstall Django?
This happens when I install side by side versions of Python on Gentoo. Whenever I install a new version, I have to either reinstall the new ones or make a symlink to the old site-packages.
Because each installation of Python uses its own directory to store libraries. On a Mac, they are in /Library/Python/2.x/site-packages/. Presumably you originally installed Django in the 2.5 directory, but it isn't yet in the 2.6 one. You can symlink it there if you want to, or reinstall it using the new version.
Add site-packages to PYTHONPATH:
export PYTHONPATH="/home/jerome/bin/django-1.1/lib/python2.6/site-packages:$PYTHONPATH"
Worked on Ubuntu, with a python/django virtual environment using virtualenv and pip.
Source: http://benfsayer.com/importerror-no-module-named-django-core-management/
I use Bitnami's Django installer, and this happened for me when I wasn't in their custom shell, which I believe sets related python path environment variables. I ran ./use_djangostack in the root of the Bitnami package and then was successful running the server again.