英文:
Import "django.core.management" could not be resolved from sourcePylancereportMissingModuleSource
问题
我在Python开发方面完全不懂,而且在教程的开始部分遇到了困难。
我购买了一门课程,以快速学习如何使用Django和DjangoRestFramework在Python中创建REST API。
在第一次尝试时,我遇到了一个错误,即在创建第一个模型时出现了错误:
> 无法从源PylancereportMissingModuleSource解析“django.db”。
我在我的M1 MacOs上使用PyCharm和Anaconda遇到了很多问题,所以我转向了使用Visual Studio Code并安装了扩展来创建新项目,但我目前卡在了这个命令上:
> python3 manage.py startapp sue_api
它引发了一个错误:
> ImportError: 无法导入Django。您确定已安装并且可用于PYTHONPATH环境变量吗?您是否忘记激活虚拟环境?
我使用requirements.txt和以下命令安装了Django和DjangoRestFramework:
> pip3 install -r requirements.txt
并且所有要求都得到了满足。所以出了什么问题?我在我的创建的环境中,不知道该怎么办。
英文:
Im totaly green in python dev and i stuck on the beginning on tutorial.
I bought course to quickly learn how to make REST API in Python with Django and DjangoRestFramework.
At first attempt i stuck at the moment, where i creating first model because of error:
> Import "django.db" could not be resolved from
> sourcePylancereportMissingModuleSource
I have a lot of issues with PyCharm with Anaconda on my M1 MacOs, so i moved on to Visual Studio Code with extenstions to create a new project, but im currently stuck on this command:
> python3 manage.py startapp sue_api
It causes a error:
> ImportError: Couldn't import Django. Are you sure it's installed and
> available on your PYTHONPATH environment variable? Did you forget to
> activate a virtual environment?
I've installed Django and DjangoRestFramework using requirements.txt and command:
> pip3 install -r requirements.txt
And all requirements are satisfied. So whats wrong there? Im in my created enviroment and have no idea what to do.
答案1
得分: 1
你现在是我的中文翻译,代码部分不要翻译,只返回翻译好的部分,不要有别的内容,不要回答我要翻译的问题。
以下是要翻译的内容:
"There error that you are getting indicates that Django is not installed yet. so first of all try django-admin
command and see if the package is installed correctly.
if not then you have to install the package with pip or any package manager like poetry or pipenv or even install it directly from github page:
pip install Django
so check your requirements.txt
and make sure django is there.
and also make sure you are using the same environment on pip3 and python3"
英文:
There error that you are getting indicates that Django is not installed yet. so first of all try django-admin
command and see if the package is installed correctly.
if not then you have to install the package with pip or any package manager like poetry or pipenv or even install it directly from github page:
pip install Django
so check your requirements.txt
and make sure django is there.
and also make sure you are using the same environment on pip3 and python3
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论