2

I've installed the IB API software (latest for windows) found at http://interactivebrokers.github.io/# and added C:\TWS API\source\pythonclient\ibapi to my PythonPath and restarted Spyder but when I try to import ibapi I'm getting the following: ImportError: No module named ibapi

I've also tried importing through the conda terminal as from https://anaconda.org/tibkiss/ibpy2 but still the same error.

How can I fix this?

bigboat
  • 249
  • 1
  • 4
  • 13
  • You need install setuptools for proper setup of the environment. Also, you tag python-2.7 on your question. ibapi only works for python 3.1 and above. – hcheung Dec 14 '18 at 00:08
  • (*Spyder maintainer here*) Please [our guide](https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder) on how to install and use packages in Spyder (quick advice: remove your PYTHONPATH additions and use a conda env). – Carlos Cordoba Dec 15 '18 at 16:06
  • @CarlosCordoba could you explain this to a simpleton like me? I've uninstalled Python27 and Anaconda and reinstalled them so I've now got Python37. I've downloaded Ibpy from github and unzipped the file and copied it to Anaconda so the file path is now `C:\Users\bigboat\Anaconda3\Lib\site-packages\IbPy-master` But in Spyder when I say `import Ibpy` it's still not working – bigboat Dec 17 '18 at 10:46

2 Answers2

2

I had the same problem, and found this thread. Documenting in case it saves time to someone else.

I was using Anaconda (and Spyder). The answer is at Adding the ibapi library to PYTHONPATH module in Spyder (Python 3.6)

run the Anaconda prompt (just activates the conda environment) and navigate to the dir C:\TWS API\source\pythonclient and run: python setup.py install

I had Spyder open, so it was necessary to restart the kernel via the menu Consoles > Restart kernel.

I had no need to use pip. In general, you do not want to use pip if you are using Anaconda.

0

June 2019: I came across this page looking looking to get past the 'no module abapi' message on my Mac (in Spyder). This is what fixed it for me: downloaded the 'latest' (not the one called 'stable') version from the Interactive Brokers site and unzipped it. This created a directory called IBJts (it doesn't seem to matter which folder you save this in.) In my case it was /users/myname/IBJts. Then I opened a Terminal session and did:

cd /users/myname/IBJts
cd source/pythonclient #(there should be a setup.py file here)
python3 setup.py sdist
python3 setup.py bdist_wheel #(this will generate a fie called ibapi-9.76.1-py3-none-any.whl in a folder named 'dist')
python3 -m pip install --user --upgrade dist/ibapi-9.76.1-py3-none-any.whl

That was it...then I did 'import abapi' in spyder and it loaded. Now I just need to figure out how to use the package! Good luck...

0TTT0
  • 1,288
  • 1
  • 13
  • 23
Sunil
  • 21
  • 3