Client installation issue

Hitesh11
Not getting client installed. Tried pip install kiteconnect but getting error while importing library. Please let me know the correct way of installation if i am making any mistake.

Python version that i am using 2.7

calling from notebook

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in ()
1 import logging
----> 2 from kiteconnect import KiteConnect

ImportError: No module named 'kiteconnect'
  • rakeshr
    @Hitesh11
    You can use pip install kiteconnect --upgrade --pre, to install latest kiteconnect python client.
  • Hitesh11
    still getting error. Please let me know if i need any additional dependency to be install. i am getting error no module named twisted.
  • rakeshr
    @Hitesh11
    You can install twisted separately using pip install Twisted and then install python client.
  • PREMCHANDGUPTA
    Hello All,
    Hello Rakeshr,

    I tried installing Twisted separately. But it is error out for VC++ Build tool. I have installed the build tool 2015 as well. But its not working. I am using Win7, Anaconda, Python 3.6.5. Below is the error message. Please help. Thanks.

    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
    C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
    Command "c:\pythonenvs\example\scripts\python.exe -u -c "import setuptools, toke
    nize;__file__='C:\\Users\\a587181\\AppData\\Local\\Temp\\pip-install-s33rd0p2\\T
    wisted\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().repl
    ace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --rec
    ord C:\Users\a587181\AppData\Local\Temp\pip-record-onjampxp\install-record.txt -
    -single-version-externally-managed --compile --install-headers c:\pythonenvs\exa
    mple\include\site\python3.6\Twisted" failed with error code 1 in C:\Users\a58718
    1\AppData\Local\Temp\pip-install-s33rd0p2\Twisted\
  • kuvi
    download the web installer from link below (total download 1GB +) and proceed with default installation
    https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017
  • zartimus
    @PREMCHANDGUPTA Can you uninstall the existing kiteconnect?
    `pip uninstall kiteconnect`
    `pip install kiteconnect --no-cache`

    If not working, try this
    Assuming PC is 64bit and python 3.6, download
    https://github.com/zerodhatech/python-wheels/blob/master/Twisted-17.9.0-cp36-cp36m-win_amd64.whl
    pip install path_to_download_twisted. Then try again
  • rvsw
    I'm having the same problem. Unable to install kite connect on Windows 7 with Python 3.6.0 on a 64-bit machine. I have been trying this for several weeks now. Details are appended at the end of this message.

    @zartimus thank you for providing the link wheel file. I was zerodha had mentioned it explicitly somewhere. Otherwise how can anyone figure out that there is a direct pre-existing somewhere within the zerodha the top repository that will contain the wheel.

    Also, will the real lead to any subtle problems because of the difference in the the hardware configurations on different machines. For example, I have had experiences with bugs which I had quite a bit of time trying to figure out and ultimately it led to a possibility that the underlying packages that I was using and had installed using wheel were perhaps not working properly. So, by any chance, do you know if the wheel file will be here reliably on Windows 7 64 bit platform with Python 3.6.0

    And here are the details of my struggle.

    First it was a Microsoft Visual C++ 14.0 build tools needed problem. It never worked with visual studio 2017 and ultimately I uninstalled everything and then restarted with the visual studio 15.0 DVD. Then I had to install Windows 10 is decay even though it is a Windows 7 machine. Then it started giving me a compiler problem with files so I had to add an environment variable INCLUDE with the path to the various header files. Then I had problems with the MSVCRT.lib so I had to add another environment variable LIB with the part of the various libraries.

    Finally it is giving me a problem stating that output file has not been specified when in fact I see in the make command that /OUT flag has clearly been mentioned.

    I'm now stuck at that point.
  • rvsw
    @zartimus thank you for posting the link to the wheel file. I am having similar problems and I wish zerodha had posted the link to the real file earlier. How is a customer going to figure out that there may be a wheel file existing within github repository?

    I have a question though on the reliability of the wheel files. I am having a Windows 7 64 bit machine with Microsoft Visual C++ 15 installed. Will the wheel file upwork reliably on this? The reason I ask is because I have experienced subtle bugs in another situation which ultimately turned out to be due to some kind of setup issue. I spent several days chasing bugs which I thought were in my program but ultimately turned out to be somewhere in the underlying wheel files. Can this be a problem here also?

    This is what I had faced in my continuing struggle for several weeks now to install kite connect

    Initially, I got an error saying Microsoft Visual C++ build 14.0 tools needed. I tried installing it from the web but it did not work even after installation. Then I tried installing visual studio 2017 and that did not work. Visual studio 2015 is not available on the web so I found of visuals to 2015 DVD. I uninstalled everything and installed the software through the DVD. Then I had to install Windows 10 SDK even though it was a Windows 7 machine. Then I started getting compilation errors because the header file were not present. I added an environment variable INCLUDE to point to the path of the header files. After that was completed, I started getting an error for the absence of library files will stop I added an environment variable LIB to point to the path of the library files. Finally, I'm now getting an error saying the output file is not specified when I can clearly see in the make command that the flag /OUT is clearly mentioned.

  • zartimus
    @rvsw I have described it here https://kite.trade/forum/discussion/comment/14205/#Comment_14205

    pykiteconnect uses twisted for websocket and that brings all the trouble of compiling twisted for windows platforms. To prevent this, we uploaded twisted windows wheels to our repo and hacked the setup.py to do all magic https://github.com/zerodhatech/pykiteconnect/blob/master/setup.py#L31. Depending on the os version and architecture it picks a suitable wheel from the repo and installs it. So you basically do not need visual c++ compiler at your end.

    twisted wont release wheels unless they complete this milestone. We have already worked on an alternative in asyncio which would make all our lives easier. :)

    Reply and i can help debug the issue
  • rvsw
    @zartimus thank you for your response. This is a very useful thread that you have added. I'm going to go through it bit by bit.
    Yes I do understand that twisted is a problem. I was actually trying to build it on my own because I was out of ideas. Now with your description I understand more.

    I'm a bit sick now and it will take me a few days to get back to working again. I will get back to you then.

    By the way, I used to work in a asyncio writing high-performance network servers a decade ago :-). Looks like you are from zero than happy to interact with the young people who are working in the same area :-). Brings back the memories.
  • rvsw
    @zartimus the code In the link that you provided at https://github.com/zerodhatech/pykiteconnect/blob/master/setup.py#L31 seems to install the wheel itself.

    To me it seems that if I do
    pip install kiteconnect

    It should install the wheel on its own. But that is not the case.

    Are you recommending that first reinstall the wheel from the https://github.com/zerodhatech/python-wheels/blob/master/Twisted-17.9.0-cp36-cp36m-win_amd64.whl and then simply do pip install kiteconnect

    Or is there any other procedure?

    I don't want to just try and see without explicit instructions from you because I'm apprehensive of putting the system in a state where it becomes difficult to reverse and even debug.

    Please advise. Thank you
  • zartimus
    zartimus edited July 2018
    @rvsw All i m saying is `pip install kiteconnect` should work as expected and you should not be getting any visual C++ required warning.
    Can you uninstall kiteconnect completely and try pip install kiteconnect --no-cache?

    Paste the stacktrace if you are getting any errors
  • rvsw
    rvsw edited July 2018
    @zartimus Thank yo for the response. I tried the command as you have mentioned and it gave me the following error. As you can see it is still building twisted and failing because it could not find the output file Even though it seems to be mentioned in the /OUT flag.
    But I think the main problem from what I understand is that it should not even be trying to build twisted and instead it should be installing the wheel file directly

    (Also please advise if there is any other way to Communicate directly because it may not be useful to hijack this thread and spam and discuss everything on the discussion forum. With that said, whatever you think is convenient is okay by me. Thank you again)

    running build_ext
    building 'twisted.test.raiser' extension
    creating build\temp.win-amd64-3.6
    creating build\temp.win-amd64-3.6\Release
    creating build\temp.win-amd64-3.6\Release\src
    creating build\temp.win-amd64-3.6\Release\src\twisted
    creating build\temp.win-amd64-3.6\Release\src\twisted\test
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe /c /nologo
    /Ox /W3 /GL /DNDEBUG /MD -DWIN32=1 -Ic:\users\rohit\appdata\local\programs\pyth
    on\python36\include -Ic:\users\rohit\appdata\local\programs\python\python36\incl
    ude "-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\ucrt" "-IC:\P
    rogram Files (x86)\Microsoft Visual Studio 14.0\VC\include" "-IC:\Program Files
    (x86)\Windows Kits\10\Include\10.0.14393.0\shared" /Tcsrc/twisted/test/raiser.c
    /Fobuild\temp.win-amd64-3.6\Release\src/twisted/test/raiser.obj
    raiser.c
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /nologo
    /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\user
    s\rohit\appdata\local\programs\python\python36\libs /LIBPATH:c:\users\rohit\appd
    ata\local\programs\python\python36\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86
    )\Microsoft Visual Studio 14.0\VC\lib\" /EXPORT:PyInit_raiser build\temp.win-amd
    64-3.6\Release\src/twisted/test/raiser.obj /OUT:build\lib.win-amd64-3.6\twisted\
    test\raiser.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\src/twis
    ted/test\raiser.cp36-win_amd64.lib

    LINK : warning LNK4001: no object files specified; libraries used
    LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
    LINK : fatal error LNK1159: no output file specified
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\b
    in\\link.exe' failed with exit status 1159
  • rvsw
    Updating the thread after @zartimus advised me to do so as it may help others. This is the process that I followed in order to finally get Kite installed

    Earlier problem: I was unable to build twisted on my machine and also while installing Kite connect.

    So ultimately, I decided to use the wheel file instead. I have been hesitant to install the wheel file because from my prior developers experience in network programming, files that are not specifically built for your system may lead to several errors especially in networking for hard to reproduce errors.

    Nevertheless, since I did not have any other option, I have decided to take the risk and install the wheel file.

    The one provided by zerodha did not work for me. I have Python 3.6.0 with Windows 7 on 64 bit installed and yet the wheel file meant for this architecture kept on reporting that it was not supported on this platform.

    Ultimately, I installed from https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted.
    And then after that I installed Kite connect. It still gave me a warning message but it did install Kite.

    I have yet to use it it really works.
  • npchoubey
    This is what I have done.


    ----------- Steps for install Kite for Python -------
    My system config
    Windows 7 - 64 Bits

    download Python 3.6.7 - 32 bits { https://www.python.org/ftp/python/3.6.7/python-3.6.7.exe }

    Install downloaded python { I used default setup }
    Check with command --> python -V

    Install Third party extension. Zerodha may be fixing it later but this extension is required. Extension depends on which python version we have. Since we have Python 3.6, we need to use Twisted‑18.9.0‑cp36‑cp36m‑win32.whl

    Install this extension with command --> pip install \Twisted-18.9.0-cp36-cp36m-win32.whl

    once done

    Install kiteconnet { and your dreams of making big bucks ;) }

    command --> pip install kiteconnect

    We are done !!!
  • sagarneo
    @npchoubey Thanks man! You are a life saver. :)
This discussion has been closed.