-2

So I am trying to download the Interactive Brokers API for python. I have downloaded the api as the website instructs, then I have gone to source, python client, then when I open the setup python file, the file will open to a small black screen then immediately close. I am using python 3.8. Any one have any ideas as to why this is happening (I have added the error I am receiving now bellow)? Thanks

EDIT: When I typed "C:\TWS API\source\pythonclient" into the comand prompt, and then python setup.py install, I get the error:

running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.2288.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\test-easy-install-13760.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2288.0_x64__qbz5n2kfra8p0\Lib\site-packages\

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.readthedocs.io/en/latest/easy_install.html

Please make the appropriate changes for your system and try again.
benito.cano
  • 455
  • 1
  • 3
  • 16
  • How do your run this file? Are you on windows and clicking it to run? You may see better information if you open a command prompt and run it there. – tdelaney Aug 01 '20 at 00:57
  • I have tried running it through the command prompt as well as clicking on it. I tried to run it through CMD by saying, "python setup.py install" and it said file `python: can't open file 'setup.py': [Errno 2] No such file or directory` – benito.cano Aug 01 '20 at 01:02
  • Does this answer your question? [Python: can't open file 'setup.py': \[Errno 2\] No such file or directory. Directory Change does not remove error](https://stackoverflow.com/questions/17583771/python-cant-open-file-setup-py-errno-2-no-such-file-or-directory-directo) – FishingCode Aug 01 '20 at 01:14
  • This does not help @FishingCode – benito.cano Aug 01 '20 at 02:02
  • Maybe add more details/the traceback itself to the question. the question is vague. – FishingCode Aug 01 '20 at 02:08
  • "then when I open the setup python file, the file will open to a small black screen then immediately close." Yes, if you double-click a `.py` file (or a `.bat` file, or anything else that's executable in a command-line environment), Windows will open a terminal window for the process, and close it *as soon as the program is finished running* - it doesn't care whether you've had time to read the output or not, and doesn't care whether the program was interactive or not. – Karl Knechtel Aug 01 '20 at 06:32
  • "EDIT: When I typed "C:\TWS API\source\pythonclient" into the comand prompt, and then python setup.py install, I get the error:" Okay, did you try **reading that**? It seems to me like it tells you exactly what the problem is and gives useful options for fixing it. – Karl Knechtel Aug 01 '20 at 06:32
  • @Karl Kmechtel When it open and closed the black screen and I went to import the api into the python code it said that the package was not found, so I am assuming that it was not properlly installed (I am new to programing so I am not sure)?. Also I am sorry but I am still confused as to what the solution is. Maybe you could lead me to the right direction? – benito.cano Aug 01 '20 at 06:36
  • I mean, if you aren't willing to read the error message, why would me typing the same thing into this comment box be any help? If you did read the error message and you don't understand it, then you need to explain *what it is that you don't understand*. For example, do you know what a `directory` is? Do you know what `write access` means? Do you know what an administrator account is? etc. – Karl Knechtel Aug 01 '20 at 06:37
  • I don't know what any of those are, as I was saying I am a begginer at programing. Which is why I am saying I don't understand the error. – benito.cano Aug 01 '20 at 06:39
  • What does it mean by account? What account? What is administrative access? I am not understanding the error which is why I am asking for help. – benito.cano Aug 01 '20 at 06:40
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/219029/discussion-between-karl-knechtel-and-benito-cano). – Karl Knechtel Aug 01 '20 at 06:40

1 Answers1

1

You have to go into cmd and go to the directory where you stored the API files then type python setup.py install this is assuming you have python installed. Use cd to navigate to the file location.

FATCAT47
  • 42
  • 9
  • I have python 3.5 installed. How do I use cd to navigate to the file location? (I belive what you are asking for is this "C:\TWS API\source\pythonclient", if so how do I format it?) – benito.cano Aug 01 '20 at 03:17
  • 1
    ```cd..``` twice to move back to C:\> and then ```cd "TWS API" ```(would suggest using underscores when naming your files so you don't have to use quotations) then ```cd sources``` etc. let me know if that helps – FATCAT47 Aug 01 '20 at 03:38
  • Could you write out what I shoudl put in the termianl? What does CD mean? – benito.cano Aug 01 '20 at 03:40
  • 1
    type ```cd "C:\TWS API\source\pythonclient"``` into your cmd terminal. If that's the directory where you installed the API files there should be a setup.py there. once the terminal is in the directory type ```python setup.py install ``` that should start the setup – FATCAT47 Aug 01 '20 at 05:16
  • Thank you for responding. Okay so I have tried what you recommended and now I have a new error, which I added to the edit section of my question. How can I fix this? – benito.cano Aug 01 '20 at 06:14
  • 1
    right click on cmd and click "run as administrator" then try again (upvoting my comments and answer helps me gain internet points) – FATCAT47 Aug 01 '20 at 06:38
  • Thank you again for responding. I tried running the terminal as administer and I am receiving the same error. What else could it be? – benito.cano Aug 01 '20 at 06:42
  • 1
    try ```python setup.py install --user``` (adding the --user) – FATCAT47 Aug 01 '20 at 06:49
  • To use the ```import``` function in python you need to place the file with the name of the import containing the ``` __init__``` file into ```C:\ (wherever your python installation is located) \Python\Lib\site-packages\``` – FATCAT47 Aug 01 '20 at 06:58
  • I Upvoted everything I could find on you, thank you so much for you generosity and help, you are a savior!! – benito.cano Aug 01 '20 at 06:59
  • 1
    lmfao no problem fellow human thank you and you're welcome – FATCAT47 Aug 01 '20 at 07:00