Sdk (@NotNull PsiFileSystemItem psiFile) { final VirtualFile vfile; if (psiFile instanceof PsiFile) { final PsiFile contextFile = FileContextUtil.getContextFile(psiFile); vfile = contextFile != null ? contextFile.getOriginalFile().getVirtualFile() : null; } else { vfile = psiFile.getVirtualFile(); } Sdk sdk = null; if (vfile != null) { // reality final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(psiFile.getProject()); sdk = projectRootManager.getProjectSdk(); if (sdk == null) { final List<OrderEntry> orderEntries = projectRootManager.getFileIndex().getOrderEntriesForFile(vfile); for (OrderEntry orderEntry : orderEntries) { if (orderEntry instanceof JdkOrderEntry) { sdk = ((JdkOrderEntry)orderEntry).getJdk(); } else if (OrderEntryUtil.isModuleLibraryOrderEntry(orderEntry)) { sdk = PythonSdkUtil.findPythonSdk(orderEntry.getOwnerModule()); } } } } return sdk; }