报错内容
代码语言:javascript复制C:UsersLenovoPycharmProjectsfood>python manage.py makemigrations
Traceback (most recent call last):
File "C:UsersLenovoPycharmProjectsfoodmanage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:UsersLenovoPycharmProjectsfoodmanage.py", line 22, in <module>
main()
File "C:UsersLenovoPycharmProjectsfoodmanage.py", line 13, in main
raise ImportError(
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?
django安装了,但是找不到,在控制台执行import django
也不会报错。
此时python解释器在linux的anaconda中。
环境
通过pycharm连接远程linux中的anaconda3,django4.7,python3.8
需求场景
在linux的mysql数据库进行建表操作
错误分析
我也不知道环境怎么坏了,今天上午还能正常执行python manage.py makemigrations
,晚上就不行了。参考了其他文章,是路径的问题,将执行语句更换为
C:UsersLenovo.condaenvspythonProject1python.exe manage.py makemigrations
C:UsersLenovo.condaenvspythonProject1python.exe manage.py migrate
C:UsersLenovo.condaenvspythonProject1python.exe manage.py runserver
同时将解释器环境从linux远程换到windows本地。如图:
这里虽然版本爆红,但是不影响。 然后执行带路径的命令就好了:
运行成功。 通过DataX向创建的数据库中写入hdfs的数据成功:
23/4/14更新
切换到remote环境hadoop13执行,不写绝对路径,成功。该场景是基于我的毕业设计,一开始环境的搭建就有大坑,本地环境和linux的hadoop集群中的anaconda中的环境搭建的不完全,python pyspark pysql等组件缺东少西,版本不兼容。