0

我正在学习 PYcharm 教程,该教程设置了一个投票站点,作为我的第一个 Python/Django 项目。我是新手,所以如果我问愚蠢的问题,我会提前道歉。在 admin.py 文件中,以下导入不起作用:

from MyDjangoApp.polls.models import Poll, Choice

我已经指定了我在其他帖子中找到的环境变量

DJANGO_SETTINGS_MODULE  MyDjangoApp.settings

MyDjangoApp 是我的项目名称,MyDjangoApp.settings 作为 Edit Configurations 选项卡中的值。

我还尝试按照灯泡建议安装包模型,但是当我这样做时,我收到以下错误:

Error occurred when installing packages.

The following command was executed:

packaging_tool.py install --build-dir /tmp/pycharm packaging1986982253689628475.tmp
models

The error output of the command:


Downloading/unpacking models
  Downloading models-0.9.3.tar.gz
  Running setup.py egg_info for package models
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/tmp/pycharm-packaging1986982253689628475.tmp/models/setup.py", line 25, in
 <module>
    import models
  File "models/__init__.py", line 24, in <module>
    from props import *
  File "models/props.py", line 23, in <module>
    import yaml
ImportError: No module named yaml
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "<string>", line 14, in <module>

File "/tmp/pycharm-packaging1986982253689628475.tmp/models/setup.py", line 25, in
<module>

import models

File "models/__init__.py", line 24, in <module>

from props import *

File "models/props.py", line 23, in <module>

import yaml

ImportError: No module named yaml

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pycharm
-packaging1986982253689628475.tmp/models
Storing complete log in /home/andrew/.pip/pip.log

我不确定如何进行。我已经看到了很多建议,但它们要么不起作用,要么我做得不正确。如果有人有任何建议,我将不胜感激。今天大部分时间我都在用头撞墙,我真的很希望能够继续前进。感谢任何愿意帮助新手的人。

4

1 回答 1

0

polls/admin.pyfrom models import Poll, Choice- 这是假设你有一个models.py文件旁边admin.py

于 2013-09-27T16:39:09.023 回答