简体   繁体   English

即使安装了 django,也无法运行 python manage.py runserver 命令

[英]Unable to run python manage.py runserver command even though django is installed

I am not able to run my local server through atom terminal, even though all the requirements are meant.我无法通过 atom 终端运行我的本地服务器,即使所有要求都是如此。 This is the error i get when I run python manage.py runserver,这是我运行 python manage.py runserver 时遇到的错误,

File "manage.py", line 17 ) from exc ^ SyntaxError: invalid syntax文件“manage.py”,第 17 行)来自 exc ^ SyntaxError:无效语法

I tried python3 manage.py runserver as suggested by some people online as a solution for mac users but it gave a different error,我按照网上一些人的建议尝试了 python3 manage.py runserver 作为 mac 用户的解决方案,但它给出了不同的错误,

ImportError: Couldn't import Django. ImportError: 无法导入 Django。 Are you sure it's installed and available on your PYTHONPATH environment variable?您确定它已安装并在您的 PYTHONPATH 环境变量中可用吗? Did you forge t to activate a virtual environment?您是否伪造 t 来激活虚拟环境?

Sharing the screenshot of my atom terminal.分享我的 atom 终端的截图。

Make sure you also installed django for python3.确保您还为 python3 安装了 django。 By doing pip -V you can verify that your pip belongs to the python installation you expected.通过执行pip -V您可以验证您的 pip 属于您预期的 python 安装。

You might need to use pip3 if you're running python 2 and 3 in parallel.如果您并行运行 python 2 和 3,则可能需要使用pip3 Alternatively, you can use python3 -m pip install Django to make sure it's for python 3或者,您可以使用python3 -m pip install Django以确保它适用于 python 3

Okay, this problem occurs when you use the wrong python to runserver that is, instead of using the python you used in installing your django you used another one好的,当您使用错误的 python 来运行服务器时会出现此问题,也就是说,而不是使用您在安装 django 时使用的 python 您使用了另一个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM