I
I
Intelide2016-12-04 10:21:55
Django
Intelide, 2016-12-04 10:21:55

Django not available from python3?

Good afternoon
OS debian8, I installed django via pip3
from Python 2.7.9 when I enter the import django command, no errors occur,
but when I enter the same command from python 3.5.2, an error occurs

import django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'django'

please tell me what needs to be done to make django available from python3 ?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dimonchik, 2016-12-04
@dimonchik2013

virtualenv

I
Ivan Tishchenko, 2016-12-04
@Tihon_V

Your python2 libraries are located in a directory (/usr/lib64/python/site-packages) different from python3 (/usr/lib64/python3/site-packages).
I will offer several solutions:
1. Fast:

cd $PROJECT_DIR
cat "./env" > .gitignore
python3 -m venv env
source ./env/bin/activate
pip install django

2. Installing the python3-django package in the distribution kit (you need to take into account that in addition to the jenga itself, you sometimes need "batteries" for it + a driver for the database).
3. Create a Docker / LXC environment and transfer the working directory there (I try to use this method, but so far I have not been able to connect the debugger from PyCharm to the container built with handles without docker-machine).

I
Intelide, 2016-12-04
@Intelide

solved the problem by reinstalling the system on ubuntu, everything was installed there without problems

D
Dmitry, 2016-12-04
@DemiKam

I use as a version manager of python and the necessary libraries for the project under development --> Anaconda - https://www.continuum.io/downloads
1. on the command line - conda create -n name(virtual environment name) python=?.?( python version required)
2. on the command line - source activate name(virtual environment name) --> activate the virtual environment.
3. here are two ways to install the necessary packages, pip install [name] or conda install [name].
ps If you are working with Postgresql --> the conda install psycopg2 command installs the package and all dependencies perfectly and no need to dance with a tambourine :-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question