简体   繁体   中英

Trouble importing module in Python

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.

try this
easy_install krakenex
Or
pip install krakenex
Or
read this and follow the doc https://pypi.python.org/pypi/krakenex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM