我是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
您的文件列表中不包含任何称为'cube_interface'。 'cube_interface'在哪里? – BrenBarn
您是否按照网页上的说明列表?安装prereqs,克隆repo,make等? – user2357112
说明是针对服务器的,我正在尝试构建客户端。 – spuder