Eclipse的PyDev Interactive Console,import 抛出ImportError

时间:2022-02-20 23:10:47

I have created a PythonProject in Eclipse Luna. I am trying to run python module via PyDev Interactive Console, but a simple import <ModuleName> does not work it throws the following error.

我在Eclipse Luna中创建了一个PythonProject。我试图通过PyDev交互式控制台运行python模块,但一个简单的导入 不起作用它会引发以下错误。

Traceback (most recent call last):

Traceback(最近一次调用最后一次):

File "", line 1, in

文件“”,第1行,in

File "C:\Users\SAMA0714\Downloads\eclipse\plugins\org.python.pydev_4.0.0.201504132356\pysrc\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs)

文件“C:\ Users \ SAMA0714 \ Downloads \ eclipse \ plugins \ org.python.pydev_4.0.0.201504132356 \ pysrc \ pydev_import_hook.py”,第21行,在do_import模块中= self._system_import(name,* args,** kwargs)

ImportError: No module named first

ImportError:没有名为first的模块

I have changed the working directory of console via

我已经改变了控制台的工作目录

import os
os.chdir(<to_the_src_folder_of_my_project_where_I_put_my_python_modules)

but still I face the same error. Generally when I do the import statement, If I type the first character of my module name I use to get the available modules with the name, but I do not see the names. I've look into various * question, but none were appropriate. any help is appreciated. I have also tried running the console for the present editor option in the Eclipse Console Options, but in vain. But it works fine on Eclipse Kepler version.

但我仍面临同样的错误。通常当我执行import语句时,如果我键入我的模块名称的第一个字符,我用来获取具有名称的可用模块,但是我没有看到名称。我研究了各种*问题,但没有一个是合适的。任何帮助表示赞赏。我还尝试在Eclipse控制台选项中为当前编辑器选项运行控制台,但是徒劳无功。但它在Eclipse Kepler版本上运行良好。

UPDATE PyDev Interactive Console

更新PyDev交互式控制台

Eclipse的PyDev Interactive Console,import 抛出ImportError

Project Explorer

Eclipse的PyDev Interactive Console,import 抛出ImportError

This is my on job system which is a 64-bit machine. I have a 32-bit machine at home on which python interactive console works smooth. On my home machine, I have had python on local drive c. On my job system I had installed it in documents folder which I now moved to C, but still the error persists.

这是我的工作系统,它是一台64位机器。我家里有一台32位机器,python交互式控制台工作顺畅。在我的家用机器上,我在本地驱动器c上有python。在我的工作系统上,我已经将它安装在我现在移动到C的文件夹中,但仍然存在错误。

1 个解决方案

#1


The locations in which Python looks for modules are in sys.path which can also be modified. What output do you get when printing it?

Python查找模块的位置在sys.path中,也可以修改。打印时会得到什么输出?

import sys
print sys.path

You could try adding your path to sys.path:

您可以尝试将路径添加到sys.path:

import sys
sys.path.append(<full_path_to_the_src_directory)

#1


The locations in which Python looks for modules are in sys.path which can also be modified. What output do you get when printing it?

Python查找模块的位置在sys.path中,也可以修改。打印时会得到什么输出?

import sys
print sys.path

You could try adding your path to sys.path:

您可以尝试将路径添加到sys.path:

import sys
sys.path.append(<full_path_to_the_src_directory)