Django的创建过程以及虚拟环境

首先按住 Alt+F12打开命令行

1.然后输入如下的命令行代码

django-admin startproject mysite

2.运行程序,输入:

2.py manage.py runserver

3.你的应用可以存放在任何 Python 路径 中定义的路径。在这个教程中,我们将在你的 ​manage.py​ 同级目录下创建投票应用。这样它就可以作为顶级模块导入,而不是 ​mysite ​的子模块。
请确定你现在处于 ​manage.py​ 所在的目录下,然后运行这行命令来创建一个应用:

py manage.py startapp polls

4.安装virtualenv虚拟环境

pip install virtualenv

如果在安装的过程中遇见如下错误:

Collecting virtualenvwrapper
  Downloading https://files.pythonhosted.org/packages/c1/6b/2f05d73b2d2f2410b48b90d3783a0034c26afa534a4a95ad5f1178d61191/virtualenvwrapper-4.8.4.tar.gz (334kB)
    100% |████████████████████████████████| 337kB 1.7MB/s
    Complete output from command python setup.py egg_info:
    Couldn't find index page for 'pbr' (maybe misspelled?)
    No local packages or download links found for pbr
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-install-ZU0gb8/virtualenvwrapper/setup.py", line 7, in <module>
        pbr=True,
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 268, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 313, in fetch_build_eggs
        replace_conflicting=True,
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 843, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1088, in best_match
        return self.obtain(req, installer)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1100, in obtain
        return installer(requirement)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 380, in fetch_build_egg
        return cmd.easy_install(req)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 632, in easy_install
        raise DistutilsError(msg)
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pbr')

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-ZU0gb8/virtualenvwrapper/

经过查找发现,好像是源的问题,于是切换成国内的源,运行下面三个命令:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pbr

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-deps stevedore

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-deps virtualenvwrapper

运行成功之后,再来运行:

pip install virtualenv

就可以显示成功安装了。

5.在控制台输入下列命令就可以开始使用了

virtualenv  venv

6.如何启用这个软件

输入

./venv/Scripts/activate

之后就可以看到在最前面出现了一个(venv)的样子就说明你已经打开了这个虚拟环境

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值