垃圾站 电脑技术 Python项目迁移后报错“Cannot find declaration to go to”解决方法

Python项目迁移后报错“Cannot find declaration to go to”解决方法

把Python源码拷贝到一台新的电脑(已经安装了Python环境),发现在第三方库名称上操作ctrl+鼠标左键是提示Cannot find declaration to go to

Python项目迁移后报错“Cannot find declaration to go to”解决方法插图
一、出现这个有一种情况是没有安装这个第三方库,解决办法就是pip安装

二、另一种情况是安装过了此第三方库,但是依然出现Cannot find declaration to go to

1、右键点击左侧文件导航栏整个项目文件夹,然后右击选择 Mark Directory as -> Sources Root

Python项目迁移后报错“Cannot find declaration to go to”解决方法插图1
2、点击 File -> Settings 进入设置界面,在设置界面点击 Project:python -> Python Interpreter -> -> Python 3.10(选择你电脑安装的Python) -> OK 完成

Python项目迁移后报错“Cannot find declaration to go to”解决方法插图2
3、经过上面处理,如果问题依然存在,那边就要重新创建虚拟化的项目环境,做完一个项目后,你希望能够不再一次安装它依赖的模块,就能在另外一个系统上直接运行,那么就进行虚拟化项目环境,而我的项目本身就进行了电脑迁移,所以很符合这个解决办法

File -> New Project

Python项目迁移后报错“Cannot find declaration to go to”解决方法插图3

上一篇
下一篇
联系我们

联系我们

返回顶部