用streamlit运行ChatGLM/basic_model/web_demo.py的时候,出现了module not found:
ModuleNotFoundError: No module named 'mdtex2html'
Traceback:
File "/home/haiyue/.local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)
File "/home/haiyue/code/ChatGLM3/basic_demo/web_demo.py", line 4, in <module>
    import mdtex2html
用pip install mdtex2html,装上了重新运行还是这个错误。
 贴心的GPT试图解决我的问题:
 
 但我确认了python解释器的路径确实和安装mdtex2html的路径一致…
 和Chatgpt进行了一番交谈,我终于定位到了问题。
 因为我是用下面的这条命令运行demo的:
 
 所以这可能和直接调用python解释器运行会有一些差别。
 推测streamlit安装的路径,要和代码里面import的包安装路径一致。
 
 此处定位到了原因。
 但由于此前已经安装过streamlit,而且执行pip install streamlit,会自动安装到用户级环境中。
 因此需要继续解决这个问题。
 最终解决方案:执行pip install --force-reinstall streamlit即可。
 



















![LeetCode [中等]3. 无重复字符的最长子串](https://img-blog.csdnimg.cn/789cfd7b57774baeaf9921242df53dea.png)