如何让 IntelliJ 识别常见的 Python 模块? [英] How do I get IntelliJ to recognize common Python modules?

查看:27
本文介绍了如何让 IntelliJ 识别常见的 Python 模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 IntelliJ 10 IDEA 终极版.

我创建了一个新文件 Test.py,并且 IntelliJ 已正确切换到 Python 解析模式.(我可以通过输入d"来确认这一点,它会弹出def"作为建议,正确点击 tab 会给我def :")

但是,当我尝试此代码时...

导入操作系统cwd = os.getcw 

发生了两件事......

  1. 我在 os 下方看到一个波浪形的下划线,将鼠标悬停在它上面会给我一条未解析的引用 'os'"消息
  2. 当我期待看到getcwd"时,我没有收到任何按 Ctrl 空格键的建议.

我假设这一定是我没有正确配置 IntelliJ 以处理 python 模块的结果,但我不知道我错过了什么.

有没有 IntelliJ/Python 用户可以帮助我?

解决方案

只需创建并添加 Python SDK

文件 ->项目结构 ->项目 ->项目 SDK ->新的

并选择您的 Python 解释器的安装路径(对于例如,Windows 中的 C:Python26 和 Linux 中的 /usr/bin/python2.7 作为主路径.

相关讨论:http://devnet.jetbrains.net/thread/286883>

I'm using IntelliJ 10 IDEA Ultimate Edition.

I've created a new file Test.py, and IntelliJ has correctly switched to Python parsing mode. (I can confirm this by typing "d", it pops up "def" as a suggestion, and hitting tab correctly gives me "def :")

However, when I try this code...

import os

cwd = os.getcw <Ctrl-space>

Two things happen....

  1. I get a squggly underline underneath os and hovering over it gives me a "Unresolved reference 'os'" message
  2. I get no suggestions hitting Ctrl-space above, when I'm expecting to see "getcwd".

I'm assuming that this must be a result of my not configuring IntelliJ properly in order to handle python modules, but I have no idea what it is I'm missing.

Any IntelliJ/Python users able to help me out?

解决方案

Just create and add Python SDK

File -> Project Structure -> Project -> Project SDK -> new

and select the installation path of your Python interpreter (for example, C:Python26 in windows and /usr/bin/python2.7 in Linux) as the home path.

Related discussion: http://devnet.jetbrains.net/thread/286883

这篇关于如何让 IntelliJ 识别常见的 Python 模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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