Pycharm:“未解析的引用"打开工作项目时 IDE 上的错误 [英] Pycharm: "unresolved reference" error on the IDE when opening a working project

查看:184
本文介绍了Pycharm:“未解析的引用"打开工作项目时 IDE 上的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简介

我在 git 存储库上有一个 Python 项目.对于大多数团队成员来说一切正常,我们可以在不同平台(Windows、Linux)上使用 Pycharm 同步和编辑代码,没有任何问题

I have a Python project on a git repository. Everything works ok for most of the team members, we can sync the code and edit it without any problem with Pycharm on different platforms (Windows, Linux)

问题

在其中一台计算机上,除了 Python 的内置库(即 import datetime 正在工作)之外,几乎每次导入的代码中都出现了未解析的引用".这台电脑运行的是 Mac 版的 Pycharm.

On one of the computers we are getting "Unresolved reference" all over the code on almost every import with the exception of Python's built in libraries (i.e. import datetime is working). This computer is running the Mac version of Pycharm.

问题

任何人都知道如何解决这个问题?因为大多数导入都无法识别代码完成和导航槽 goto->declaration 等不起作用.Mac 版本有任何已知问题吗?

Anyone knows how to solve this?, since most of the imports are not recognized code completion and navigation trough goto->declaration and so on is not working. Is there any known issue with the Mac version?

提前致谢!

推荐答案

关键是将您的源目录标记为源根目录.请尝试以下操作:

The key is to mark your source directory as a source root. Try the following:

  • 在项目视图中,右键单击 Python 源目录
  • 在对话框菜单中选择将目录标记为 > 源根目录

该文件夹现在应该显示为蓝色而不是米色,以表明它是一个 Python 源文件夹.

The folder should now appear blue instead of beige, to indicate it is a Python source folder.

您还可以通过对 PyCharm 中已有的项目执行以下操作,在 PyCharm 首选项中进行配置:

You can also configure this in PyCharm preferences by doing the following for a project that is already in PyCharm:

  • 在 Mac 工具栏中,选择 PyCharm > 首选项
  • 在打开的窗口中,从左侧的菜单窗格中选择项目结构
  • 如有必要,请在中间窗格中选择您的项目
  • 在右窗格中右键单击您的 Python 源,然后从菜单对话框中选择

这篇关于Pycharm:“未解析的引用"打开工作项目时 IDE 上的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆