0

I'm running python 3.6 via anaconda 3, using Visual Studio Code.

I followed instructions like these (Interactive Brokers API install) and downloaded the package to a local directory of mine say: c:\dev\pyib, so now the code is in c:\dev\pyib\IbPy-master

I open that directory in command line and run

python setup.py install

All runs ok.

But then my program, which is in c:\dev\pyib says Module not found. (In my case ibapi). The linter is also showing red.

There is no other python installed on this pc.

Where did the package install to? and how do I check that? What will I find where the package installed itself to that shows me its there?

Or do I have to use a trial-and-error with the linter and sys.path.append()? (I tried that with the directory where the files are downloaded to - to no avail)

I'm trying to set up the PYTHONPATH using the "env" in launch.json from Visual Studio Code, as shown in this unaccepted answer.

Current sys.path:

'c:\\dev\\pyIb', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\python36.zip', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\DLLs', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-
packages', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Babel-2.5.0-py3.6.egg', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib', 
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin'

I deleted the ib directory and re-ran the install. The last line says: Writing C:\Users\user\AppData\Local\Continuum\anaconda3\Lib\site-pac‌​kages\IbPy2-0.8.0-py‌​3.6.egg-info So is the location of the egg-info the location of my undetected module? The actual folder in the site-packages is called ib.

Or could my problems be because of a difference in Lib vs. lib with the lowercase in the sys.path and the uppercase in the actual directory?

But the real question here is still: HOW DO I KNOW WHERE the package was installed what should I search for?

pashute
  • 3,965
  • 3
  • 38
  • 65
  • you can check installed packages with `pip freeze` or similar conda command `conda list --export` – aiven Jan 07 '18 at 16:49
  • Are you using virtual environment? – Emmanuel Mtali Jan 07 '18 at 16:52
  • I'm using out of the box Visual Studio Code with Python – pashute Jan 07 '18 at 16:52
  • `pip freeze` lists an `IbPy2` package... hmmm! thanks Aiven! Although that didn't answer my question: WHERE was the package installed, and how do I know that... Anyway: import IbPy2 didn't work either. And why did the linter autocomplete my command ibapi.wrapper... – pashute Jan 07 '18 at 16:55
  • Try to check -> `python_location/PythonXY-AM\Lib\site-packages` – Emmanuel Mtali Jan 07 '18 at 16:58
  • I deleted the ib directory and re-ran the install. The last line says: `Writing C:\Users\user\AppData\Local\Continuum\anaconda3\Lib\site-packages\IbPy2-0.8.0-py3.6.egg-info` So is the location of the egg-info the location of my undetected module? – pashute Jan 07 '18 at 17:06
  • Could it be because of a difference in Lib vs. lib with the lowercase in the sys.path and the uppercase in the actual directory? – pashute Jan 07 '18 at 17:27

1 Answers1

0

This answer is specific for anaconda3 Python and packages installed using python setup.py install (which is actually using distutils)

Take a look at anaconda3\Lib\site-packages you should see a directory for the package you installed.

The way to know for sure where your package is, is by doing a pip list then trying to pip uninstall and re-install again using the python setup.py install: Here are the detailed instructions:

When uninstalling, pip will tell you it cannot because it was done via distutils.

You'll get a message like this:

DEPRECATION: Uninstalling a distutils installed project (ibpy2) has been deprecated and will be removed in a future version. 
This is due to the fact that uninstalling a distutils project will only partially uninstall the project.

You'll be prompted to continue anyway. If you choose No, then you can find the directory in

C:\Users\<yourusername>\AppData\Local\Continuum\anaconda3\Lib\site-packages

Thanks to Emanuel Mtali for pointing me in the right direction

Some more information:

The problem I had was due to a stupid mistake of mine. I was running setup of a different (but related) package not used anymore. IbPy2 instead of TwsAPI. I was supposed to run the setup.py of the package installed via the latest version of the MSI from IB, and NOT the IbPy2 package. :-(

pashute
  • 3,965
  • 3
  • 38
  • 65