0

In my ec2 machine i need to run a django project, I do the below thinks:

Install python 3.4:

sudo yum install python34

ok, now i create a virtual enviroment for python 3:

virtualenv -p python3 .venv3

at this point activate my venv:

source .venv3/bin/activate

all done! Now i have to install django:

pip install django

the installation was ok but when i try to check my django version:

python -c "import django; print(django.get_version())"

system return the error "No module name django found" How is possible? In my machine there is also python 2.7 installed. I try outside the virtualenv to remove django with:

sudo python -m pip uninstall django

all done, but in my .venv3 enviroment the issue is still present. How can i fix the problem?

i also tried to reinstall django like this:

 pip install --upgrade --force-reinstall django

response:

Collecting django Using cached https://files.pythonhosted.org/packages/56/0e/afdacb47503b805f3ed213fe732bff05254c8befaa034bbada580be8a0ac/Django-2.0.6-py3-none-any.whl Collecting pytz (from django) Using cached https://files.pythonhosted.org/packages/dc/83/15f7833b70d3e067ca91467ca245bae0f6fe56ddc7451aa0dc5606b120f2/pytz-2018.4-py2.py3-none-any.whl Installing collected packages: pytz, django Found existing installation: pytz 2018.4 Uninstalling pytz-2018.4: Successfully uninstalled pytz-2018.4 Successfully installed django-2.0.6 pytz-2018.4

but when i try:

pip freeze

response is:

gunicorn==19.8.1 pytz==2018.4 virtualenv==16.0.0

Why django isn't installed?

thanks in advance

9
  • With you venv activated: what does python --version and django-admin --version return? Commented Jun 12, 2018 at 9:35
  • Hi,python --version return Python 3.4.8, Commented Jun 12, 2018 at 9:49
  • django-admin --version return:Traceback (most recent call last): File "/home/ec2-user/.venv3/bin/django-admin", line 7, in <module> from django.core.management import execute_from_command_line ImportError: No module named 'django'" Commented Jun 12, 2018 at 9:50
  • 1
    I had the same issue few time ago. I don't remember exactly How I solved this one, but try : pip install Django==2.0.6 or pip install django --user Commented Jun 13, 2018 at 7:10
  • 1
    Do you still need help getting a Django application installed on AWS? I would highly recommend using Elastic Beanstalk. I followed the guide here: docs.aws.amazon.com/elasticbeanstalk/latest/dg/… last week with Django2.1 and Python 3.6 and it works great. Elastic Beanstalk will help keep things simple. Commented Aug 6, 2018 at 12:20

1 Answer 1

1

The answer to your question depends on your version of python so you need to install pip3

sudo apt-get install python3-pip

Then, you have to create a virtual environment with venv

pip3 -p python3.6 virtualenv name

After that install Django:

pip3 install Django

As in the recent version, you can use

apt-get install python3-django

Or you can simply do the follwing:

sudo apt-get install python3 virtualenvwrapper

mkvirtualenv <venv> -p python3

workon <venv>

--system-site-packages

pip install Django

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.