Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'KiteConnect' #70

Closed
rajeshdua123 opened this issue Jan 24, 2020 · 5 comments
Closed

ImportError: cannot import name 'KiteConnect' #70

rajeshdua123 opened this issue Jan 24, 2020 · 5 comments

Comments

@rajeshdua123
Copy link

Hi,

I recently purchased Kiteconnect API and trying to install kiteconnect in python. I am getting the following error -

ImportError: cannot import name 'KiteConnect'

Here is what I did -

  1. First command pip install --upgrade kiteconnect - successfully installed
  2. Second command python.exe -m pip install -U pip setuptools - successfully updated
  3. Third command pip show kiteconnect and here is the output I got -

Name: kiteconnect
Version: 3.8.1
Summary: The official Python client for the Kite Connect trading API
Home-page: https://kite.trade
Author: Zerodha Technology Pvt ltd. (India)
Author-email: talk@zerodha.tech
License: MIT
Location: c:\users\user.conda\envs\tensorflowgpu1\lib\site-packages\kiteconnect-3.8.1-py3.6.egg
Requires: requests, six, pyOpenSSL, enum34, python-dateutil, autobahn, pywin32
Required-by:

Please help.

Thanks

@rajeshdua123
Copy link
Author

Hello Zerodha Team,

Please help.

Thanks

@vividvilla
Copy link
Member

vividvilla commented Jan 27, 2020

We have tested in Linux and it seems working. This could be windows related issue. Can you run pip freeze and paste the logs here? Also how are you importing it, I guess its from kiteconnect import KiteConnect?

@tushar2708
Copy link

tushar2708 commented Jan 29, 2020

This seems to be happening with the latest versions of pip.

From pip's message it seems that zerodha team will need to do a change in their setup.py :

Below is the error/warning message that comes on

pip install kiteconnect

    Running setup.py install for kiteconnect ... done
  DEPRECATION: kiteconnect from https://files.pythonhosted.org/packages/b9/0b/ab3c02f062e7c36d2e530c7bab47f47978431ee35a4ef1d5a8597528f648/kiteconnect-3.8.1.tar.gz#sha256=bc667aff2a2ffca23d1fdaf1375b765d823834aea7561369f1b6831669230000 did not indicate that it installed an .egg-info directory. Only setup.py projects generating .egg-info directories are supported. pip 20.2 will remove support for this functionality. A possible replacement is for maintainers: updating the setup.py of kiteconnect. For users: contact the maintainers of kiteconnect to let them know to update their setup.py.. You can find discussion regarding this at https://github.com/pypa/pip/issues/6998.

The above error that pip is giving has a link to an issue that is already logged in the context of kiteconnect. (pypa/pip#6998)

Corresponding kiteconnect forum page: https://kite.trade/forum/discussion/4335/could-not-find-egg-info-directory-in-install-record-for-kiteconnect

But not sure why the support thread has been closed, telling the user:
Successfully installed kiteconnect` means kiteconnect is installed. Could not find .egg directory is a warning that you ignore. Please do not create unnecessary threads unless it is a valid query.

This is not correct. The package installation is, in fact failing.

@joeirimpan
Copy link
Member

joeirimpan commented Feb 7, 2020

@tushar2708 Package installation is showing a deprecation warning. I m checking into it now.

Installation

(testenv) ➜  test pip install kiteconnect                                                                                                                                                                                                                                                                                     
Collecting kiteconnect                                                                                                                                                                                                                                                                                                        
  Using cached kiteconnect-3.8.1.tar.gz (24 kB)                                                                                                                                                                                                                                                                               
Requirement already satisfied: requests>=2.18.4 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from kiteconnect) (2.22.0)                                                                                                                                                                                
Requirement already satisfied: six>=1.11.0 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from kiteconnect) (1.14.0)
Requirement already satisfied: pyOpenSSL>=17.5.0 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from kiteconnect) (19.1.0)
Requirement already satisfied: enum34>=1.1.6 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from kiteconnect) (1.1.6)
Requirement already satisfied: python-dateutil>=2.6.1 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from kiteconnect) (2.8.1)
Requirement already satisfied: autobahn[twisted]>=17.10.1 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from kiteconnect) (20.1.3)
Requirement already satisfied: idna<2.9,>=2.5 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from requests>=2.18.4->kiteconnect) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from requests>=2.18.4->kiteconnect) (2019.11.28)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from requests>=2.18.4->kiteconnect) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from requests>=2.18.4->kiteconnect) (1.25.8)
Requirement already satisfied: cryptography>=2.8 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from pyOpenSSL>=17.5.0->kiteconnect) (2.8) 
Requirement already satisfied: txaio>=20.1.1 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from autobahn[twisted]>=17.10.1->kiteconnect) (20.1.1)
Requirement already satisfied: twisted>=15.4.0; extra == "twisted" in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from autobahn[twisted]>=17.10.1->kiteconnect) (19.10.0)
Requirement already satisfied: zope.interface>=3.6.0; extra == "twisted" in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from autobahn[twisted]>=17.10.1->kiteconnect) (4.7.1)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from cryptography>=2.8->pyOpenSSL>=17.5.0->kiteconnect) (1.13.2)
Requirement already satisfied: Automat>=0.3.0 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from twisted>=15.4.0; extra == "twisted"->autobahn[twisted]>=17.10.1->kiteconnect) (0.8.0)
Requirement already satisfied: PyHamcrest>=1.9.0 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from twisted>=15.4.0; extra == "twisted"->autobahn[twisted]>=17.10.1->kiteconnect) (2.0.0)
Requirement already satisfied: attrs>=17.4.0 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from twisted>=15.4.0; extra == "twisted"->autobahn[twisted]>=17.10.1->kiteconnect) (19.3.0)
Requirement already satisfied: hyperlink>=17.1.1 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from twisted>=15.4.0; extra == "twisted"->autobahn[twisted]>=17.10.1->kiteconnect) (19.0.0)
Requirement already satisfied: incremental>=16.10.1 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from twisted>=15.4.0; extra == "twisted"->autobahn[twisted]>=17.10.1->kiteconnect) (17.5.0)
Requirement already satisfied: constantly>=15.1 in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from twisted>=15.4.0; extra == "twisted"->autobahn[twisted]>=17.10.1->kiteconnect) (15.1.0)
Requirement already satisfied: setuptools in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from zope.interface>=3.6.0; extra == "twisted"->autobahn[twisted]>=17.10.1->kiteconnect) (45.1.0)
Requirement already satisfied: pycparser in /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.8->pyOpenSSL>=17.5.0->kiteconnect) (2.19)
Building wheels for collected packages: kiteconnect
  Building wheel for kiteconnect (setup.py) ... done
  WARNING: Legacy build of wheel for 'kiteconnect' created no files.
  Command arguments: /home/testuser/.virtualenvs/testenv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6x5yz0mj/kiteconnect/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6x5yz0mj/kiteconnect/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().repla
ce('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-nikobdjf
  Command output: [use --verbose to show]
  Running setup.py clean for kiteconnect
Failed to build kiteconnect
Installing collected packages: kiteconnect
    Running setup.py install for kiteconnect ... done
  DEPRECATION: kiteconnect from https://files.pythonhosted.org/packages/b9/0b/ab3c02f062e7c36d2e530c7bab47f47978431ee35a4ef1d5a8597528f648/kiteconnect-3.8.1.tar.gz#sha256=bc667aff2a2ffca23d1fdaf1375b765d823834aea7561369f1b6831669230000 did not indicate that it installed an .egg-info directory. Only setup.py projects 
generating .egg-info directories are supported. pip 20.2 will remove support for this functionality. A possible replacement is for maintainers: updating the setup.py of kiteconnect. For users: contact the maintainers of kiteconnect to let them know to update their setup.py.. You can find discussion regarding this at 
https://github.com/pypa/pip/issues/6998.
Successfully installed kiteconnect

Version

(testenv) ➜  test pip show kiteconnect
Name: kiteconnect
Version: 3.8.1
Summary: The official Python client for the Kite Connect trading API
Home-page: https://kite.trade
Author: Zerodha Technology Pvt ltd. (India)
Author-email: talk@zerodha.tech
License: MIT
Location: /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages/kiteconnect-3.8.1-py3.8.egg
Requires: requests, six, pyOpenSSL, enum34, python-dateutil, autobahn
Required-by: 

Egg directory

(testenv) ➜  test unzip -l /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages/kiteconnect-3.8.1-py3.8.egg
Archive:  /home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages/kiteconnect-3.8.1-py3.8.egg
  Length      Date    Time    Name
---------  ---------- -----   ----
     8201  2020-02-07 15:20   EGG-INFO/PKG-INFO
      324  2020-02-07 15:20   EGG-INFO/SOURCES.txt
        1  2020-02-07 15:20   EGG-INFO/dependency_links.txt
      157  2020-02-07 15:20   EGG-INFO/requires.txt
       12  2020-02-07 15:20   EGG-INFO/top_level.txt
        1  2020-02-07 15:20   EGG-INFO/zip-safe
     3842  2020-01-06 13:13   kiteconnect/__init__.py
      335  2020-01-06 13:13   kiteconnect/__version__.py
    33363  2020-01-06 13:13   kiteconnect/connect.py
     2574  2020-01-06 13:13   kiteconnect/exceptions.py
    31968  2020-01-06 13:13   kiteconnect/ticker.py
     4006  2020-02-07 15:20   kiteconnect/__pycache__/__init__.cpython-38.pyc
      508  2020-02-07 15:20   kiteconnect/__pycache__/__version__.cpython-38.pyc
    26314  2020-02-07 15:20   kiteconnect/__pycache__/connect.cpython-38.pyc
     3687  2020-02-07 15:20   kiteconnect/__pycache__/exceptions.cpython-38.pyc
    25049  2020-02-07 15:20   kiteconnect/__pycache__/ticker.cpython-38.pyc
---------                     -------
   140342                     16 file

Sys path has correct path to egg to imports to work fine

(testenv) ➜  test ipython
/home/testuser/.local/lib/python3.8/site-packages/IPython/core/interactiveshell.py:925: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
  warn("Attempting to work in a virtualenv. If you encounter problems, please "
Python 3.8.1 (default, Jan 22 2020, 06:38:00) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sys                                                             

In [2]: sys.path                                                               
Out[2]: 
['/home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages',
 '/home/testuser/.local/bin',
 '/usr/lib/python38.zip',
 '/usr/lib/python3.8',
 '/usr/lib/python3.8/lib-dynload',
 '',
 '/home/testuser/.local/lib/python3.8/site-packages',
 '/usr/lib/python3.8/site-packages',
 '/home/testuser/.local/lib/python3.8/site-packages/IPython/extensions',
 '/home/testuser/.ipython',
 '/home/testuser/.virtualenvs/testenv/lib/python3.8/site-packages/kiteconnect-3.8.1-py3.8.egg']

We will fix the warning before pip moves to minor version.

@joeirimpan
Copy link
Member

Fixed in https://pypi.org/project/kiteconnect/ v3.8.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants