我正在使用新版本的Django构建新的Django
应用。我发现Django 2.0可用(2.0.5)https://www.djangoproject.com/download/,现在尝试用pip安装它。
pip install Django==2.0.5
但它不适合我。
Collecting Django==2.0.5
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x044F7630>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x044F7850>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x044F7A50>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x044F74D0>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x044F7C30>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
Could not find a version that satisfies the requirement Django==2.0.5 (from versions: )
No matching distribution found for Django==2.0.5
我正在使用python 3.6.5
和pip 9.0.3
。这有什么不对?
答案 0 :(得分:1)
手动升级点对我来说很成功
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
在虚拟环境中。
答案 1 :(得分:0)
您可以使用
pip install Django == 1.11
这是Mac OS运行10x的那个
答案 2 :(得分:0)
按照Kanak的指示安装pip特定版本。
如果仍然出现错误,可能是因为缺少包裹。我也得到了同样的错误。最后用以下命令集解决:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var backgroundTask: UIBackgroundTaskIdentifier!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
self.registerBackgroundTask()
// Do your background work here
print("Do your background work here")
// end the task when work is completed
self.endBackgroundTask()
}
func registerBackgroundTask() {
self.backgroundTask = UIApplication.shared.beginBackgroundTask { [weak self] in
self?.endBackgroundTask()
}
assert(self.backgroundTask != UIBackgroundTaskInvalid)
}
func endBackgroundTask() {
print("Background task ended.")
UIApplication.shared.endBackgroundTask(backgroundTask)
backgroundTask = UIBackgroundTaskInvalid
}
}
在相应的目录中重新安装python:
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
安装django:
sudo make
sudo make install
如果仍然出现错误,请使用tar文件安装django:
sudo pip3 install django
要安装Django,请使用以下命令:
Download Django-x.x.x.tar.gz from django website
Cd path/where/downloaded
tar -xzvf django.tar.gz (unzip the downloaded file)
cd Django-x.x.x
检查版本的命令:
python setup.py install –user
我希望有所帮助。