简体   繁体   English

不同的“python”和“python3”版本

[英]different "python" and "python3" versions

My python --version is Python 3.9.6 And my python3 --version is Python 3.10.8我的python --version是 Python 3.9.6 而我的python3 --version是 Python 3.10.8

I believe because of this I have a problem with running flask applications in VsCode.我相信因此我在 VsCode 中运行 flask 应用程序时遇到问题。 When I run one I receive ModuleNotFoundError: No module named 'flask error, however, I did install flask module当我运行一个时,我收到ModuleNotFoundError: No module named 'flask错误,但是,我确实安装了 flask 模块

Requirement already satisfied: flask in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (2.2.2)

I know that sometimes this problem is caused by the wrong interpreter version, I tried all of them but no one worked我知道有时这个问题是由错误的解释器版本引起的,我尝试了所有这些但没有一个有效

Does anybody know what is the reason for my error and how can I fix it?有谁知道我的错误的原因是什么,我该如何解决?

Use the following code to print out the currently used interpreter.使用以下代码打印出当前使用的解释器。

import sys
print(sys.executable)

Then use the command to install flask for the current interpreter.然后使用命令为当前解释器安装flask。

<pythonpath> -m pip install flask

在此处输入图像描述

Referencing this link will help.参考此链接会有所帮助。

Try this either of this commands;试试这个命令中的任何一个; ---python3 -m venv venv ---python3 -m venv venv

--python -m venv venv ---py -m venv venv --python -m venv venv ---py -m venv venv

if that doesn't work then get your Python version and make sure you are installing the package using the correct Python version.如果这不起作用,请获取您的 Python 版本,并确保您使用正确的 Python 版本安装 package。

But If the error persists, restart your IDE and development server/script.但如果错误仍然存在,请重新启动您的 IDE 和开发服务器/脚本。

You can check if you have the Flask package installed by running the pip show Flask command.您可以通过运行 pip show Flask 命令检查是否安装了 Flask package。

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

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