You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装MarkupSafe后仍触发ModuleNotFoundError的技术问题咨询

问题:虚拟环境安装MarkupSafe后仍提示模块找不到

操作流程与问题现象

1. 创建并配置虚拟环境

# 创建虚拟环境
> virtualenv -p python3 spectap

# 激活环境并安装依赖
> . spectap/bin/activate
> pip3 install -r requirements.txt

2. 运行Flask应用触发错误

Traceback (most recent call last):
  File "/home/ec2-user/app4/app/spectap/bin/flask", line 5, in <module>
    from flask.cli import main
  File "/home/ec2-user/app4/app/spectap/local/lib/python3.6/dist-packages/flask/__init__.py", line 1, in <module>
    from markupsafe import escape
ModuleNotFoundError: No module named 'markupsafe'

3. 尝试安装MarkupSafe

(spectap) [ec2-user@ip-172-31-23-155 app]$ pip3 install MarkupSafe==2.0.1
Collecting MarkupSafe==2.0.1
  Using cached MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
Installing collected packages: MarkupSafe
  WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /home/ec2-user/app4/app/spectap/lib/python3.6/dist-packages
  sysconfig: /home/ec2-user/app4/app/spectap/lib/python3.6/site-packages
  WARNING: Additional context:
  user = False
  home = None
  root = None
  prefix = None
Successfully installed MarkupSafe-2.0.1

4. 安装后仍无法识别包

执行pip3 show markupsafe返回:

(spectap) [ec2-user@ip-172-31-23-155 app]$ pip3 show markupsafe
WARNING: Package(s) not found: markupsafe

重新运行Flask应用,依然抛出ModuleNotFoundError: No module named 'markupsafe'错误。

补充:虚拟环境内的Python路径信息

(spectap) [ec2-user@ip-172-31-23-155 app]$ python -c "import sys; print(sys.path)"
['', 
 '/home/ec2-user/app5/app/spectap/local/lib64/python3.6/site-packages', 
 '/home/ec2-user/app5/app/spectap/local/lib/python3.6/site-packages', 
 '/home/ec2-user/app5/app/spectap/lib64/python3.6', 
 '/home/ec2-user/app5/app/spectap/lib/python3.6', 
 '/home/ec2-user/app5/app/spectap/lib64/python3.6/site-packages', 
 '/home/ec2-user/app5/app/spectap/lib/python3.6/site-packages', 
 '/home/ec2-user/app5/app/spectap/lib64/python3.6/lib-dynload', 
 '/home/ec2-user/app5/app/spectap/local/lib/python3.6/dist-packages', 
 '/usr/lib64/python3.6', '/usr/lib/python3.6']

疑问

请问我忽略了什么?


内容的提问来源于stack exchange,提问作者Darth.Vader

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 21:45:26