python - 更新后损坏的python虚拟环境
问题描述
今年冬天,我一直在按照本教程开发 Flask 应用程序。今天,因此在 3 个月后,我决定再次对其进行处理,但我的所有设置似乎都已损坏。应用程序开始只是激活 virtualenv 并调用flask run
. 至于今天,命令返回:
No module named 'flask'
等等 for等等pip
,pip3
即使所有这些模块都在venv/bin
. 我唯一的猜测是,从那时起,我将系统范围内的 python 更新为 Python 3.8.3rc1,它也不知何故成为了python
venv 中的默认值,即使我在python 3.7
. 如果是这样的话,我不知道如何解决这个问题。你有什么建议吗?谢谢
解决方案
When you created your virtual environment (let's call it v
), two things happened:
v/bin/python
was a link to your system Python 3.7v/lib/python3.7
was created for packages installed to the virtual environment.
When you updated, the v
link remained the same, but now it points to Python 3.8, which will look for a library directory named python3.8
. Hence, your old Flask installation is invisible to the new Python.
Ideally, you wouldn't use your system Python for anything; install your own Python (under /usr/local/
or something), so that instead of upgrading to a new version of PYthon, you can simply install a new version along side it. Then your virtual environment can continue using whatever version of Python it was created with.
That said, you should probably just recreate your virtual environment from scratch.
推荐阅读
- c# - 在将数据导出到数据库表时,从 csv 单元格中转义逗号(,)
- javascript - 在 total.js 中,定义我可以在脚本和模板中使用的全局常量的最佳方法是什么?
- c# - 如何获得所有显示器的比例因子?
- azure-security - 如何在 Azure Policy 中使用 Microsoft.Security/complianceResults?
- php - UP-TO-DATE 正确使用多 cURL (curl_multi_select)?
- spring-boot - 如何在camel-coap-starter springboot中启动coap服务器
- javascript - TestCafe - 断言不起作用(测试的对象必须是数组等)
- c++11 - 向量的最大索引值问题
- java - 我如何让 Scanner 类读取我的完整字符串输入
- ios - 如何在 Xcode 10.3 中使用 iOS 13.2.3(dyld_shared_cache_extract_dylibs 失败)