Django未解决在Eclipse中导入 [英] Django unresolved importing in Eclipse

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

问题描述

Python $ 3.3.1(默认,2013年4月17日,22:32:14)
[GCC 4.7.3] on linux
输入help 版权,信用或许可证了解更多信息。
>>> import django
>>> django.VERSION
(1,5,1,'final',0)

嘿我正在使用Eclipse与PyDev。我的操作系统是Ubuntu 13.04,我已经安装了python 2.7和python 3.3。我使用pip和pip3安装django,用于两个python verions。我可以在Eclipse之外使用django模块,但是当我在Eclipse中导入Django时,它说

 没有名为'Django'$ b $的模块b  

我已经在互联网上寻找了几个小时的答案。我想我的PYTHONPATH包括django的位置。



这是Eclipse中的PYTHONPATH:



PS。我刚刚发现我可以在Python项目中导入Django,但是我不能在Eclipse中的Django项目中导入Django。 ub untu ub。。。。。。with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with with
在我的情况下,django安装在/usr/lib/python2.7/dist-packages/django中。



我试图做同样的事情作为你的失败。
但是我已经成功地通过执行以下操作导入django。


  1. 从... / dist-packages / django中删除PYTHONPATH

  2. 点击申请(我不是专家,但是我已经读过eclipse是在某个地方缓存)

  3. 添加... / dist- $
  4. 单击应用

  5. 创建Pydev项目并尝试导入django
    - >它在我的情况下导入。

  6. 打包Django项目
    - >在运行时创建的所有相关文件django-admin startproject XXX

我知道这是一个老问题,我也为自己发布。


Python 3.3.1 (default, Apr 17 2013, 22:32:14) 
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 5, 1, 'final', 0)

Hey I am using Eclipse with PyDev. My OS is Ubuntu 13.04 and I have installed both python 2.7 and python 3.3. I installed django using pip and pip3 for both python verions. I can use django module outside Eclipse but when I import Django in eclipse, it says

No module named 'Django'

I already looked for an answer on the internet for few hours now. I think my PYTHONPATH includes django location.

Here's the PYTHONPATH in Eclipse:

PS. I just discovered that I can "import Django" in Python projects, but I cannot "import Django" in Django projects in Eclipse. o.O

解决方案

I had same problem with ubuntu 12.04 + eclipse 3.7.2 + django 1.3.1. In my case django was installed in "/usr/lib/python2.7/dist-packages/django".

I tried to do almost as same as yours and failed. But I have succeeded to import django by doing followings.

  1. Remove ".../dist-packages/django" from PYTHONPATH
  2. Click on apply (I am not an expert but I've read eclipse is caching somewhere)
  3. Add ".../dist-packages" intead
  4. Click on apply
  5. Create an Pydev project and try to import django -> it get imported in my case.
  6. Crate an Django project -> All relevant files as created as you run "django-admin startproject XXX"

I know this is an old question by I post this for myself too.

这篇关于Django未解决在Eclipse中导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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