热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何为python3.3安装django-Howtoinstalldjangoforpython3.3

Ihadpython2.6.1becauseitwasoldIdecidetoinstallpython3.3.2but,whenItypepythonin

I had python 2.6.1 because it was old I decide to install python 3.3.2 but, when I type "python" in my mac it prints it is version 2.6.1 and when I type python3 it shows that this is 3.3.2. I installed django 1.6 but when I check, understand that it is installed for old version of python (python 2.6.1). I want to instal it for my python 3.3.2 what should I do? any way to uninstall python 2.6.1 and when I enter python in terminal it's version be 3.3.2? I have mac os 10.6.8

我有python 2.6.1,因为它是旧的,我决定安装python 3.3.2,但是,当我在mac中输入“python”时,它会打印出版本2.6.1,当我输入python3时,它显示这是3.3.2。我安装了django 1.6,但是当我检查时,要知道它是为旧版本的python (python 2.6.1)安装的。我想为我的python 3.3.2安装它,我该怎么做?有没有办法卸载python 2.6.1,当我在终端输入python时,它的版本是3.3.2?我有mac os 10.6.8

4 个解决方案

#1


27  

You could use pip to manage the package for you. If pip is not installed. use

您可以使用pip来为您管理包。如果没有安装pip。使用

sudo easy_install pip

to install it. Then

安装它。然后

pip3 install django

would install django for your python3.

将为您的python3安装django。

#2


7  

Use python3 to call python version 3 on the command line.

在命令行上使用python3调用python版本3。

For projects you can use virtual environments:

对于项目,您可以使用虚拟环境:

$ python # this will be version 2
$ python3 -m venv myenv
$ source myenv/bin/activate
$ python # this will be version 3

where myenv will be the folder that hosts the libraries and binaries for that virtual environment. It will automcatically use the python version that was used to initialize this venv - in this case python3. This has the effect that once you activate the venv you can use python there and it will be version 3.

myenv将是为该虚拟环境托管库和二进制文件的文件夹。它将自动使用用于初始化该venv的python版本——在本例中是python3。这样做的效果是,一旦激活了venv,就可以在那里使用python,它将是版本3。

#3


1  

to setup django in pyton3

在pyton3中安装django

  1. sudo apt-get install python3-pip
  2. sudo apt-get安装python3-pip
  3. sudo pip3 install virtualenv
  4. sudo pip3 virtualenv安装
  5. virtualenv -p /usr/bin/python3.X venv
  6. virtualenv - p /usr/bin/python3.X venv
  7. source venv/bin/activate
  8. 源venv / bin /激活

congrats you have setup python3 django and now have many packages to work with

恭喜您已经安装了python3 django,并且现在有许多包可以使用

Note: X stands for the version of python

注意:X代表python版本

#4


0  

To install django for python3, you need to use pip3 instead of pip.

要为python3安装django,您需要使用pip3而不是pip。

python defaults to python2. pip defaults to pip for python2. So, when you install pip using whatever package manager you have, you are essentially installing pip for python2.

python python2违约。对于python2, pip默认为pip。因此,当您使用任何包管理器安装pip时,您实际上是在为python2安装pip。

To remove Python2: $sudo apt remove python

要删除Python2: $sudo apt,请删除python

To install pip for python3: $sudo apt install python3-pip

要为python3安装pip: $sudo apt安装python3-pip

To install pip for python2: $sudo apt install python-pip

要为python2安装pip: $sudo apt安装python-pip

Note: I am using apt package manager. You should use the package manager for your OS.

注意:我使用apt软件包管理器。您应该在操作系统中使用包管理器。


推荐阅读
author-avatar
缅甸菲菲
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有