Installing Django On Ubuntu 16.04, Python3
Solution 1:
1st: You didn't explicitly say so, but I am assuming you are using linux based on your mention of apt-get
The simplest way to get django on your python 3.6 is to fix pip. This is a pretty good overview of how to get the libraries that pip needs based on error messages such as yours. You just need to apt install a few packages.
Once you have all the dependencies installed for pip3 to run, try installing django again. Note: since you have python3 already, I'd make sure you are calling the right pip3, you can do this by calling:
pip3 -V
If the 'pip3' command is calling the pip3 in 3.5, then use the full path of the pip3 in python 3.6 instead.
Alternatively
You can try copying django from your lib/site-packages folder from your python3.5 installation to your python3.6 installation. The big gotcha is that you need to make sure to copy all the dependencies for django as well. You can ether look them up in the django config or you can try and use it and copy them over one at a time based on the error messages.
Unsolicited Advice: I would strongly suggest using virtualenvs to make this process much easier. I use pyenv and pyenv-virtualenv here, and have really loved them.
Solution 2:
16.04 is a LTS release. As such it is locked to python 3.5. You may have noticed that there were no packages in the Xenial repositories and had to install python 3.6 from alternate sources. Just be careful with that since things can break at the system level. In the end I went with building python from source and generating a django venv using.
python3.6 -m venv mydjangoproject
See this post for more details.
See this gist for a working Ubuntu16.04 Python 3.6.3 example
Solution 3:
#allow to add latest python version-
sudo add-apt-repository ppa:deadsnakes/ppa
#update-
sudo apt update
#installing python3.6 and pip package manager-
sudo apt install python3.6 python3-pip
#update for alternative version of python-
sudo update-alternatives --install /usr/bin/python3 python3/usr/bin/python3.6 1
#configuring python 3.6-
sudo update-alternatives --config python3
#install django -
sudo apt install python3-django
#adding project name-
django-admin startproject projectname
#cd to project dir-
cd projectname
#add your ip add using vim or any editor in settings.py inside []-
nano ~/projectname/projectname/settings.py
#Run the server-
python3 manage.py runserver 0.0.0.0:8000
#run at browser using 127.0.0.1:8000
Post a Comment for "Installing Django On Ubuntu 16.04, Python3"