Cannot install Django 2 Beta 1 on Ubuntu Server 16.04

本小妞迷上赌 提交于 2020-01-06 06:06:57

问题


I'm trying to install Django 2 beta 1 on an Ubuntu Server 16.04 using the command line shown on Django's download page without success.

The given command line is: pip install --pre django but when I run it, it is trying to install Django 1.11.6. (Downloading Django-1.11.6-py2.py3-none-any.whl (6.9MB))

Does anyone know how I can successfully install the beta ?


回答1:


Write explicit the version of Django you want to install:

pip install --pre Django==2.0b1

The option --pre (prerelease) can be also left out.

EDIT (after comment):

This definitely works as I have tried it. To list all versions of a package I use a dirty solution like:

pip install django==0

As pip can't find this nonexisting version it returns a list with all available versions (from versions: ...). The last version there is 2.0b1.

EDIT:

I strongly assume you're using Python 2. That would explain why the installation fails. If you want to try out Django 2, you'll need Python 3.
This is what the official documentation says:

Django 2.0 supports Python 3.4, 3.5, and 3.6. We highly recommend and only officially support the latest release of each series.

Using virtual environments installing Django 2.0 could look like this:

  1. Install virtualenv (check this here).

  2. Create new virtual environment called djangobeta with python3. Execute the following command in the shell:

    virtualenv -p python3 djangobeta

  3. Install Django 2.0 beta 1:

    pip install --pre django




回答2:


I found a solution: I uninstalled every version of Python I had (2.7, 3.5, 3.6) as well as Pip.

Then installed only Python 3.5 and installed Pip via a python script retrieved by Curl (had to do this way otherwise apt was installing Python 2.7 along with Pip) with these commands:

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python3 get-pip.py

Finally, I installed the Django 2 beta1 with the original command:

pip install --pre Django


来源:https://stackoverflow.com/questions/46929519/cannot-install-django-2-beta-1-on-ubuntu-server-16-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!