Django设置-无法导入unipath [英] Django settings -- could not import unipath

查看:50
本文介绍了Django设置-无法导入unipath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道自己在做什么错.请你帮助我好吗?我具有以下目录结构:

I could not figure out what I'm doing wrong. Could you please help me? I have the following directory structure:

project-repository
  \-- my-project
       \--manage.py
       \--my-project
             \--__init__.py
             \--urls.py
             \--wsgi.py
             \--settings
                    \--__init__.py
                    \--local.py
                    \--base.py

local.py 中,导入 base.py .在 base.py 中,我有 from unipath导入路径.当我尝试运行django-admin shell --settings = my-project.settings.local 时,它显示了一个错误:

In the local.py I import base.py. In base.py I have from unipath import Path. When I try to run django-admin shell --settings=my-project.settings.local it shows me an error:

Error: Could not import settings 'my-project.settings.local' (Is it on sys.path?): No module named unipath

当我执行 pip冻结时,它会向我显示:

When I do pip freeze it shows me:

Unipath==0.2.1

,我可以轻松地将其导入python控制台.我在PYTHONPATH上也有 project-repository my-project .

and I can easily import it in python console. Also I have project-repository and my-project on PYTHONPATH.

这是 unipath .__ file __ 输出:

/home/User/.virtualenvs/django.1.4/local/lib/python2.7/site-packages/unipath/__init__.pyc

这是 sys.path 输出的其中一行:

/home/User/.virtualenvs/django.1.4/local/lib/python2.7/site-packages

能否请您指出我做错了什么?

Could you please point me to what I'm doind wrong?

推荐答案

似乎我发现了问题所在.我以为我搞得一团糟.我已经在全球范围内安装了django和其他应用程序(很早就开始开发该项目了).然后,我安装了virtualenvwrapper并创建了virtualenv.在virtualenv中工作,我安装了必需的依赖项和Django.但是,当我尝试运行该程序时,我运行了django的全局安装版本.结果,存在一些不兼容性.卸载全局软件包后,一切正常.

It seems like I figured out the problem. The think was that I did a lot of mess. I had django and other apps installed globaly (long before I started developing the project). Then I installed virtualenvwrapper and created virtualenv. Working in the virtualenv I installed the required dependencies and the django. But when I was trying to run that I ran the globally installed version of django. As a result there were some incompatibilities. After I uninstalled global packages, everithing is ok.

我怎么知道的?非常感谢Jeff Knup和他的帖子以正确的方式启动Django 1.4项目.我完成了所描述的步骤以及运行的时间

How I figured out it? Thanks a lot to Jeff Knup and his post Starting a Django 1.4 Project the Right Way. I walked through the described steps and when I ran

(my-virtualenv)$ which django-admin.py

它向我显示了以下路径:

it showed me the following path:

/usr/local/bin/django-admin

它应该具有:

$HOME/.virtualenvs/

这表明出现了问题.

非常感谢大家尝试帮助我.

Thanks a lot for everybody for trying to help me.

这篇关于Django设置-无法导入unipath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆