问题描述
操作系统:OSX Sierra
Python:3.5
我正在尝试导入并在OSX上的Sublime Text 3中使用cmd + b运行它。
I'm trying to import krakenex and run it with cmd + b in Sublime Text 3 on OSX.
我希望能够运行(或其他任何示例)。
I expect to be able to run the example open-positions.py (or any other).
按cmd + b时,我得到
import krakenex
ImportError:没有名为krakenex的模块
When pressing cmd + b, I get
"import krakenexImportError: No module named krakenex"
如果我创建一个只显示 print'hello world'的新文件,然后按cmd + b,则它确实会打印 hello world。
If I create a new file that just says "print 'hello world'" and then press cmd + b, it does print 'hello world'.
但是,当我在open-positions.py中按cmd + b时,不会导入krakenex。
However, krakenex is not imported when I press cmd + b within open-positions.py.
问题可能很基本。我前天学习了python,昨天安装了Anaconda,而我对API的经验很少。抱歉,无能。
The problem is probably very basic. I learned python the day before yesterday, installed Anaconda yesterday, and I have very little experience with APIs. Apologies for the incompetence.
我从,将其解压缩,然后在其中运行
python3 setup.py install
提取的目录。
然后我用Sublime Text 3打开整个提取的文件夹。
然后,在open-positions.py中,如果按cmd + b,我会收到错误消息。
I downloaded the zip file from https://github.com/veox/python3-krakenex/, extracted it, then ranpython3 setup.py install
within that extracted directory.I then opened that whole extracted folder with Sublime Text 3.Then, within open-positions.py, if I press cmd + b, I get said error message.
完整的输出是
非常感谢。
推荐答案
这是你的问题。瞧,您的程序是用Python 2编写的。如果您在Python 3中运行它,它会说。
Here is your problem. See, your program is written in Python 2. Had you run it in Python 3, it would say SyntaxError: Missing parentheses in call to 'print'
.
您已将该模块安装到python3中,并且正在从ST3运行python2。
You've installed that module into your python3 and are running python2 from ST3.
这篇关于Python中的问题导入模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!