gpt4 book ai didi

python - 使用 pip 更新到 Django 1.7

转载 作者:行者123 更新时间:2023-11-28 22:47:42 24 4
gpt4 key购买 nike

我从 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

这是我的错误信息。

但是当我运行的时候

python
import django
print(django.get_version())

我得到 1.7。我可以使用这样的版本还是必须重新安装它?会成功吗?

谢谢!

最佳答案

这是因为你第一次安装 django 时,你执行了 sudo pip install django,它以根用户(或 super 用户)的身份在你的全局 Python 解释器中安装了 django。

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

如果您没有任何其他 Django 项目,那么这实际上不会产生任何负面影响 - 但作为最佳实践,您应该使用 virtual environments这样您就可以轻松地测试库的版本。

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

关于python - 使用 pip 更新到 Django 1.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25949775/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com