2014-01-16 46 views
1

我是python的新手,我试图为led立方体编写一个简单的程序。首先,我需要执行提供的其他示例程序之一,但是当我尝试运行python程序时,出现错误“No module named cube_interface”。Python - 没有名为foo的模块

现在,在您将此问题标记为重复并将我引用到7,776个类似问题的堆栈溢出之前,让我告诉您透露我已经尝试实施其他14个SO问题上提供的解决方案,然后是3个博客,修复这个错误,没有运气。

操作系统:Mac OSX 10.8.1
的Python:2.7.5
回购:https://github.com/chadharrington/all_spark_cube

示例程序为src/tetris.py

该模块为src/all_spark_cube_client

├── Makefile 
    └── src 
     ├── LICENSE.txt 
     ├── all_spark_cube_client 
     │   ├── __init__.py 
     │   └── __init__.pyc 
     ├── all_spark_cube_client.egg-info 
     │   ├── PKG-INFO 
     │   ├── SOURCES.txt 
     │   ├── dependency_links.txt 
     │   ├── not-zip-safe 
     │   ├── requires.txt 
     │   └── top_level.txt 
     ├── build 
     │   ├── bdist.macosx-10.9-intel 
     │   └── lib 
     │    └── all_spark_cube_client 
     │     └── __init__.py 
     ├── client_demo.py 
     ├── colors.py 
     ├── dist 
     │   └── all_spark_cube_client-0.1-py2.7.egg 
     ├── load_test.py 
     ├── setup.py 
     ├── supervisord.conf 
     ├── supervisord_init_script.debian 
     ├── supervisord_init_script.redhat 
     └── tetris.py 

当我尝试运行tetris.py程序时,出现错误“No module named ..”

python tetris.py 
Traceback (most recent call last): 
    File "tetris.py", line 5, in <module> 
    from all_spark_cube_client import CubeClient 
    File "/Users/sowen/Code/all_spark_cube/software/clients/python_client/src/all_spark_cube_client/__init__.py", line 8, in <module> 
    from cube_interface import CubeInterface 
ImportError: No module named cube_interface 

许多答案建议添加pwd。/Library/Python等..到PYTHONPATH。我尝试过独立实施所有这些建议,甚至将所有建议合并到一个frakenstein路径中,如图所示,但没有运气。

cd ~/Code/all_spark_cube/software/clients/python_client 
export PYTHONPATH=$PATH:$PYTHONPATH:`pwd`:`pwd`/src:.:/Library/Python/2.7/site-packages/ 

我试图建立Python模块

$sudo python setup.py build 
running build 
running build_py 
file all_spark_cube_client.py (for module all_spark_cube_client) not found 
file all_spark_cube_client.py (for module all_spark_cube_client) not found 

我试着安装Python模块(它不给任何错误,但我仍然感到无法运行tetris.py)

cd ~/Code/all_spark_cube/software/clients/python_client/src/ 
sudo python setup.py install 

如何执行tetris.py程序?

其他资源

http://docs.python.org/2/using/mac.html
http://www.confusedcoders.com/random/python-module-importerror-no-module-named-pocketsphinx

+2

您的文件列表中不包含任何称为'cube_interface'。 'cube_interface'在哪里? – BrenBarn

+0

您是否按照网页上的说明列表?安装prereqs,克隆repo,make等? – user2357112

+0

说明是针对服务器的,我正在尝试构建客户端。 – spuder

回答

3

你忘了建立cube_interface

参见:https://github.com/chadharrington/all_spark_cube/tree/master/software/thrift

您需要用gen_py工具来构建这个。

即:(我假设 :):

cd /path/to/all_spark_cube/software/thrift/ 
make 
cp cube_interface.py /path/to/python/site-packages 
+0

谢谢!'make'没有工作,但我认为我在正确的轨道上'make:thrift:没有这样的文件或目录 make:*** [gen-py]错误1 ' – spuder

+0

_显然要安装** thrift **。请仔细按照他们的指示* :) –

+0

我需要客户端。他们的指示是针对服务器的, – spuder

相关问题