使用pip更新到Django 1.7

时间:2022-03-27 19:20:47

I updated from Django 1.5.8 to 1.7:

我从Django 1.5.8更新到1.7:

pip install Django==1.7
Downloading/unpacking Django==1.7
  Downloading Django-1.7-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: Django
  Found existing installation: Django 1.5.8
    Uninstalling Django:
      Successfully uninstalled Django
  Rolling back uninstall of Django
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 671, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 901, in move_wheel_files
    pycompile=self.pycompile,
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/wheel.py", line 247, in move_wheel_files
    clobber(source, dest, False, fixer=fixer, filter=filter)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/wheel.py", line 209, in clobber
    shutil.copy2(srcfile, destfile)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/bin/django-admin.py'

Storing debug log for failure in /Users/stefanieness/Library/Logs/pip.log

This is my error message.

这是我的错误信息。

But when I run

但当我运行

python
import django
print(django.get_version())

I get 1.7. Can I use the version like that or do I have to reinstall it? Will it work?

我得到1.7。我可以使用这样的版本吗?还是需要重新安装?会工作吗?

Thank you!

谢谢你!

1 个解决方案

#1


4  

This is because the first time you installed django, you did sudo pip install django, which has installed django in your global Python interpreter as the root user (or the superuser).

这是因为在第一次安装django时,您做了sudo pip安装django, django已经在全局Python解释器中作为根用户(或超级用户)安装了django。

You can only have one version of django in your global Python interpreter, so once you upgrade it, any of your django applications that are using the global Python interpreter (in other words, not using a virtual environment) will be automatically upgraded to 1.7

您只能在您的全局Python解释器中有一个django版本,因此一旦您升级它,任何使用全局Python解释器(换句话说,不使用虚拟环境)的django应用程序都将自动升级到1.7。

If you don't have any other django projects, then this doesn't really have any negative effects - but as a best practice, you should use virtual environments so that you can easily test versions of libraries.

如果您没有任何其他django项目,那么这实际上没有任何负面影响——但是作为一种最佳实践,您应该使用虚拟环境,以便能够轻松地测试库的版本。

To solve your immediate problem, you need to sudo pip install -U django which will upgrade django to the latest stable release.

要解决当前的问题,您需要sudo pip安装-U django,它将django升级到最新的稳定版本。

#1


4  

This is because the first time you installed django, you did sudo pip install django, which has installed django in your global Python interpreter as the root user (or the superuser).

这是因为在第一次安装django时,您做了sudo pip安装django, django已经在全局Python解释器中作为根用户(或超级用户)安装了django。

You can only have one version of django in your global Python interpreter, so once you upgrade it, any of your django applications that are using the global Python interpreter (in other words, not using a virtual environment) will be automatically upgraded to 1.7

您只能在您的全局Python解释器中有一个django版本,因此一旦您升级它,任何使用全局Python解释器(换句话说,不使用虚拟环境)的django应用程序都将自动升级到1.7。

If you don't have any other django projects, then this doesn't really have any negative effects - but as a best practice, you should use virtual environments so that you can easily test versions of libraries.

如果您没有任何其他django项目,那么这实际上没有任何负面影响——但是作为一种最佳实践,您应该使用虚拟环境,以便能够轻松地测试库的版本。

To solve your immediate problem, you need to sudo pip install -U django which will upgrade django to the latest stable release.

要解决当前的问题,您需要sudo pip安装-U django,它将django升级到最新的稳定版本。