Django installation and import with two Pythons - django

I'm trying to install Django on my computer, but none of the method I followed seems to work. I tried with pip as described on the Django website, I tried with the setup.py file, and when the installation is done with both methods, I can't import Django :
ImportError: No module named 'django'
For information, I have two Python 3.3 on my computer (32 and 64 bits) in case it change something.
Thanks for helping.
T.

Related

Conda dependent packages(rdkit) will not install properly for use in web servers(importError:DLL load failed). Is there an alternative install method?

UPDATE 1: PIL and RDKIT produced import errors because the .dll files were not placed in /venv//Lib/site-packages
I removed both packages from environment and commented out their code from my project.
Next I updated the base base environment:
conda update conda #from base env
Then I upgraded pip and setuptools and reinstalled pillow:
python -m pip install pip --upgrade
pip install setuptools --upgrade
pip install pillow
I can now add my PIL content back to the project and it will work just fine on the production server, without rdkit installed.
RDKIT is only available as a conda install, it still does not install properly and breaks PIL in the process(rdkit depends on pillow). I have reinstalled from both the rdkit and conda-forge channels. Neither work.
What is the proper way to fix this problem? I feel like the hack around of moving .dll files is risky and not a good solution.
UPDATE 0: RDKIT will not load into any server
I created a basic django project similar to what you would find in the tutorial with no static files. The project successfully published to the Apache server describe below in the original post and in Windows 10 IIS. Next modified the models.py to import rdkit and both servers gave the import error and the site would not display.
Original post:
RDKIT is the only package not loading into our production server.
We successfully set up a Wampserver to run Apache and host our Django project . . .but have to comment out all the code associated with rdkit for it to work. This inhibits many required features.
There were no issues using rdkit in Django's test server.
Primary wsgi error:
from .rdBase import rdkitVersion as __version__\r, referer: http://localhost/APP/
ImportError: DLL load failed: The specified module could not be found.\r, referer: http://localhost/APP/
Relevant packages and version details:
Windows 10
Django 2.2
Python 3.7
conda 4.8.2
rdkit 2019.09.3 conda-forge
Wampserver 3.2
Apache 2.4.41
mod-wsgi 4.7.1
postgresql 10
The methods in this blog describe how we setup the production server. With one minor change, we did not alter the httpd_vhosts.conf file and only setup the standard localhost.
The error is reproducible by trying to import rdkit(or one of its methods) into any file needed to host a web application in the described environment.
We found this 2016 thread on the rdkit sourceforge and it sounds like someone else was having a similar problem on a Linux system. This is our first time setting up a server and we have not been successful at translating the recommended fix from linux to windows. There was no follow up to know if the recommendation was attempted let alone successful.
These 2012 slides lend us to believe someone was trying to overcome a similar issue in linux (slide 9)
How would a package need to be altered to allow it to load into a webserver?
Thank you, we greatly appreciate your time and assistance.

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.

No module named 'chartit';

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

No solutions for django.core.management error

I know that this question has been asked and asked again, but none of the solutions seem to works for me. I'm using Django 1.9 with Python 2.7 on Windows 8.1. When I try to run the development server from my projects manage.py I get the ImportError: No module named django core.management.
I only have one version of python
I'm not using a virtual environment
C:\Python27 and C:\Python27\Scripts are included in my path
I can import django in python and get the version number
I can import management from django.core in python
my manage.py was created using pydev and begins with "#!/usr/bin/env python" as seems appropriate according to other answers
I have already uninstalled and reinstalled django via pip
It is possible I might have messed something up when trying to change from 32 bit to 64 bit python in order to interface with Matlab.
Start python from shell, the same way you did when the import works:
>>> import os
>>> os.environ['PYTHONPATH']
'/the/python/path'
Copy this path, and in your manage.py add:
sys.path.append('/the/python/path')
from django.core.management import execute_from_command_line

ImportError: No module named apps from django-grappelli

I was working on one django project on my old machine and it was working fine.
Now I am trying to shift my django development environment to new machine (Linux). As a dependency in my project, I am using django-grappelli in it.
I have installed the django-grappelli using following command
sudo pip install --upgrade django-grappelli
It is installed successfully, but now I am trying to run my application and it is giving me following error.
File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/__init__.py", line 1, in <module>
from grappelli.dashboard.dashboards import * File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/dashboards.py", line 13, in <module>
from grappelli.dashboard import modules File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/modules.py", line 11, in <module>
from django.apps import apps as django_apps ImportError: No module named apps
I have search around and tried many suggestions, but didn't work. If I am uninstalling the grappelli, It is goving me error for
No module named grappelli
Can anyone suggest where am I doing mistake?
Django version is 1.6
I have tried different things based on my older setup in which all is working fine.
Downgrading the grappelli to version 2.5.3 worked form me. It was not working with 2.6.1 (latest varsion). Not very sure about if is this the issue with 2.6.1 grappelli version or is there any prerequisite for it.
I have uninstalled the 2.6.1 and installed 2.5.3 grappelli, and it resolved my issue.
The problem isn't with grapelli, that is being installed correctly. The problem is that django 1.6 does not have the apps folder, or at least your instance of django 1.6 and my instance of django 1.6 (I looked into 1.6.5) both don't have the apps folder.
I'm not sure what you're using the apps namespace for, but that's where the problem is.
django-grappelli 2.6 is not compatible with Django 1.6.
The apps folder was created in 1.7 alpha stage in this commit:
https://github.com/django/django/commit/860c2c8bc5c77194c41464655851379bf512a052