V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
commoccoom
V2EX  ›  Python

设置 Django 失败。。。

  •  
  •   commoccoom · 2015-10-23 09:30:43 +08:00 · 3385 次点击
    这是一个创建于 3079 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  2015-10-23 22:57:47 +08:00
    问题解决了 :
    http://stackoverflow.com/questions/8069029/on-windows-virtualenv-is-not-being-used-with-i-run-a-python-program

    直接 django-admin startproject mysite
    而不是 django-admin.py startproject mysite

    真是坑啊!
    22 条回复    2015-10-23 22:58:42 +08:00
    xavierskip
        1
    xavierskip  
       2015-10-23 09:42:08 +08:00
    环境变量没设置好吧
    commoccoom
        2
    commoccoom  
    OP
       2015-10-23 09:46:04 +08:00
    @xavierskip 在 virtualenv 虚拟环境里安装的 Django
    yongzhong
        3
    yongzhong  
       2015-10-23 10:20:03 +08:00
    用默认的命令
    glasslion
        4
    glasslion  
       2015-10-23 10:24:33 +08:00
    @commoccoom 首先确认 django 安装成功了:
    pip freeze 以及在 python shell 里 import django 的结果是什么?
    commoccoom
        5
    commoccoom  
    OP
       2015-10-23 10:28:35 +08:00
    @yongzhong
    django-admin.py startproject 这个还不是默认的命令吗?
    commoccoom
        6
    commoccoom  
    OP
       2015-10-23 10:32:06 +08:00
    @glasslion

    pip freeze

    Django==1.7.1
    wheel==0.24.0


    import django 也是正常的
    yongzhong
        7
    yongzhong  
       2015-10-23 10:37:59 +08:00
    @commoccoom windos 下眼拙看错了,你是否装了多个版本的 python?
    glasslion
        8
    glasslion  
       2015-10-23 10:42:35 +08:00
    @commoccoom 拿确实蛮诡异的。可以试试在 django-admin.py 前加上完整的 python 路径

    `D:\...\virtualenv\scripts\python django-admin.py startproject`
    有可能你安装过多个 python , 直接运行 .py 文件 没有关联到正确的 python 上
    xavierskip
        9
    xavierskip  
       2015-10-23 11:17:11 +08:00
    提示找不到模块,你就在相同的环境进 python 解释器 import 模块试一下呗?
    kidblg
        10
    kidblg  
       2015-10-23 11:30:38 +08:00
    @glasslion 确实,有可能没找到正确的 python 。
    FingerLiu
        11
    FingerLiu  
       2015-10-23 17:17:52 +08:00
    pip list 看下
    commoccoom
        12
    commoccoom  
    OP
       2015-10-23 17:51:46 +08:00
    @xavierskip
    import django 没有错误

    virtualenv 配置环境变量怎么配置?
    commoccoom
        13
    commoccoom  
    OP
       2015-10-23 17:53:37 +08:00
    @FingerLiu
    pip list

    Django(1.71)
    pip(7.1.2)
    setuptools(18.2)
    wheel(0.24.0)
    commoccoom
        14
    commoccoom  
    OP
       2015-10-23 18:00:06 +08:00
    @yongzhong
    就装了 2.7.9
    windfarer
        15
    windfarer  
       2015-10-23 18:45:20 +08:00 via Android
    在 Windows 上折腾 Web 开发坑蛮多的
    commoccoom
        16
    commoccoom  
    OP
       2015-10-23 20:37:44 +08:00
    @windfarer

    想学习 django
    xavierskip
        17
    xavierskip  
       2015-10-23 21:09:44 +08:00
    @commoccoom
    你的 django 路径肯定有问题

    你试一下?
    commoccoom
        18
    commoccoom  
    OP
       2015-10-23 22:03:12 +08:00
    kn007
        19
    kn007  
       2015-10-23 22:07:05 +08:00
    @commoccoom 你不是说你安装了 2.7.9 么,截图里版本不对
    commoccoom
        20
    commoccoom  
    OP
       2015-10-23 22:17:39 +08:00
    @kn007
    2.7.9 是办公室的机器上,我自己的安装了 2.7.10 ,都是同样的问题
    commoccoom
        21
    commoccoom  
    OP
       2015-10-23 22:49:11 +08:00
    commoccoom
        22
    commoccoom  
    OP
       2015-10-23 22:58:42 +08:00
    @xavierskip
    @glasslion

    已经解决 感谢帮助!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1512 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 23:56 · PVG 07:56 · LAX 16:56 · JFK 19:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.