python的模块导入问题_Python中的问题导入模块

1586010002-jmsa.png

Versions

OS: OSX Sierra

Python: 3.5

What am I trying to achieve?

I'm trying to import krakenex and run it with cmd + b in Sublime Text 3 on OSX.

What do I expect to happen?

I expect to be able to run the example open-positions.py (or any other).

What happens instead?

When pressing cmd + b, I get

"import krakenex

ImportError: No module named krakenex"

If I create a new file that just says "print 'hello world'" and then press cmd + b, it does print 'hello world'.

However, krakenex is not imported when I press cmd + b within open-positions.py.

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.

I downloaded the zip file from https://github.com/veox/python3-krakenex/, extracted it, then ran

python3 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.

The full output is

raceback (most recent call last):

File "/Users/Norbert/Downloads/python3-krakenex-master/examples/open-positions.py", line 1, in

import krakenex

ImportError: No module named krakenex

[Finished in 0.1s with exit code 1]

[shell_cmd: "python" -u "/Users/Norbert/Downloads/python3-krakenex-master/examples/open-positions.py"]

[dir: /Users/Norbert/Downloads/python3-krakenex-master/examples]

[path: /usr/bin:/bin:/usr/sbin:/sbin]

Much appreciated.

解决方案If I create a new file that just says print 'hello world' and then press cmd + b, it does print hello world.

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'.

You've installed that module into your python3 and are running python2 from ST3.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值