【发布时间】:2021-07-22 12:01:55
【问题描述】:
我试图在我的管理文件中创建一个新的超级用户,我收到了这个错误。
PS C:\Users\sefni\Desktop\AtlasStore> py manage.py createsuperuser
SystemCheckError: System check identified some issues:
ERRORS:
store.Product.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".
问题是我在迁移到我的数据之前已经安装了枕头,因为我有我的 0001_initial.py,所以它运行成功。
这是我再次尝试安装枕头时出现的错误。
PS C:\Users\sefni\Desktop\AtlasStore> pip install pillow
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip install pillow
+ ~~~
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我的管理文件的内容:
from django.contrib import admin
from .models import Category, Product
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
list_display = ['name', 'slug']
prepopulated_fields = {'slug': ('name',)}
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ['title', 'author', 'slug', 'price',
'in_stock', 'created', 'updated']
list_filter = ['in_stock', 'is_active']
list_editable = ['price', 'in_stock']
prepopulated_fields = {'slug': ('title',)}
VENV 文件夹:
【问题讨论】:
-
嘿,这看起来像是 Python 环境的问题。显然您的系统甚至找不到 pip 命令。你在使用虚拟环境吗?如果是这样,您需要先激活它。
-
@ErikKalkoken 嗨,我已经更新了我的帖子。我有 VENV 不知道我还需要做什么
-
是的。 VENV 是你的虚拟环境,但它似乎没有被激活。例如
PS C:\Users\sefni\Desktop\AtlasStore>前面应该有一个(venv)。试试这个命令venv/Scripts/Activate.ps1激活是(假设你的虚拟环境的名字是venv) -
或者,您可以通过单击状态栏中的 Python 标记在 VS Code 中选择 venv,然后选择您的 venv 作为环境。,