pkjmesra / PKScreener

A Python-based stock screener for NSE, India. PKScreener is an advanced free stock screener to find potential breakout stocks from NSE and show its possible breakout values. It also helps to find the stocks which are consolidating and may breakout, or the particular chart patterns that you're looking specifically to make your decisions.
https://github.com/pkjmesra/PKScreener
MIT License
162 stars 69 forks source link

Error faced while running pytest -v ImportError: cannot import name 'shutdown' from 'pkscreener.globals' #179

Closed Redbro1 closed 2 months ago

Redbro1 commented 2 months ago

I tried various stuff but its giving error this is the pytest -v results:

platform linux -- Python 3.12.5, pytest-8.3.2, pluggy-1.5.0 -- /home/hextron/project/pkscreen/bin/python
cachedir: .pytest_cache
rootdir: /home/hextron/project/pkscreen/PKScreener/test
configfile: pytest.ini
plugins: mock-3.14.0, cov-5.0.0, typeguard-4.3.0
collecting 31 items                                                                                                                                                                                                 
------------------------------------------------------------------------------------------------ live log collection ------------------------------------------------------------------------------------------------
2024-09-05 19:49:30 DEBUG Initializing backend: None results/PKDevTools_cache
2024-09-05 19:49:30 DEBUG Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)
2024-09-05 19:49:30 DEBUG Opening connection to /home/hextron/project/pkscreen/PKScreener/test/results/PKDevTools_cache.sqlite:responses
2024-09-05 19:49:30 DEBUG Initialized SQLiteDict with serializer: None
2024-09-05 19:49:30 DEBUG Opening connection to /home/hextron/project/pkscreen/PKScreener/test/results/PKDevTools_cache.sqlite:redirects
2024-09-05 19:49:30 DEBUG get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary/^NSEI
2024-09-05 19:49:30 DEBUG Entering get()
2024-09-05 19:49:30 DEBUG url=https://query2.finance.yahoo.com/v10/finance/quoteSummary/^NSEI
2024-09-05 19:49:30 DEBUG params={'modules': 'financialData,quoteType,defaultKeyStatistics,assetProfile,summaryDetail', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false', 'symbol': '^NSEI'}
2024-09-05 19:49:30 DEBUG  Entering _get_cookie_and_crumb()
2024-09-05 19:49:30 DEBUG cookie_mode = 'basic'
2024-09-05 19:49:30 DEBUG   Entering _get_cookie_and_crumb_basic()
2024-09-05 19:49:30 DEBUG ('CREATE TABLE IF NOT EXISTS "_cookieschema" ("strategy" VARCHAR(255) NOT NULL PRIMARY KEY, "fetch_date" DATETIME NOT NULL, "cookie_bytes" BLOB NOT NULL) WITHOUT ROWID', [])
2024-09-05 19:49:30 DEBUG ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0])
2024-09-05 19:49:30 DEBUG Starting new HTTPS connection (1): fc.yahoo.com:443
2024-09-05 19:49:30 DEBUG ('CREATE TABLE IF NOT EXISTS "_kv" ("key" VARCHAR(255) NOT NULL PRIMARY KEY, "value" VARCHAR(255)) WITHOUT ROWID', [])
2024-09-05 19:49:30 DEBUG ('SELECT "t1"."key", "t1"."value" FROM "_kv" AS "t1" WHERE ("t1"."key" = ?) LIMIT ? OFFSET ?', ['^NSEI', 1, 0])
2024-09-05 19:49:30 DEBUG Entering _fetch_ticker_tz()
2024-09-05 19:49:30 DEBUG  Entering get()
2024-09-05 19:49:30 DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/^NSEI
2024-09-05 19:49:30 DEBUG params=frozendict.frozendict({'range': '1d', 'interval': '1d'})
2024-09-05 19:49:30 DEBUG   Entering _get_cookie_and_crumb()
2024-09-05 19:49:30 DEBUG cookie_mode = 'basic'
2024-09-05 19:49:30 DEBUG    Entering _get_cookie_and_crumb_basic()
2024-09-05 19:49:30 DEBUG ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0])
2024-09-05 19:49:30 DEBUG Starting new HTTPS connection (2): fc.yahoo.com:443
2024-09-05 19:49:30 ERROR Failed to get ticker '^NSEI' reason: HTTPSConnectionPool(host='fc.yahoo.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x77607dcdfd70>: Failed to establish a new connection: [Errno 111] Connection refused'))
2024-09-05 19:49:30 DEBUG Exiting _fetch_ticker_tz()
2024-09-05 19:49:30 DEBUG Entering history()
2024-09-05 19:49:30 DEBUG ^NSEI: Yahoo GET parameters: {'range': '1d', 'interval': '1d', 'includePrePost': True, 'events': 'div,splits,capitalGains'}
2024-09-05 19:49:30 DEBUG  Entering get()
2024-09-05 19:49:30 DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/^NSEI
2024-09-05 19:49:30 DEBUG params={'range': '1d', 'interval': '1d', 'includePrePost': True, 'events': 'div,splits,capitalGains'}
2024-09-05 19:49:30 DEBUG   Entering _get_cookie_and_crumb()
2024-09-05 19:49:30 DEBUG cookie_mode = 'basic'
2024-09-05 19:49:30 DEBUG    Entering _get_cookie_and_crumb_basic()
2024-09-05 19:49:30 DEBUG ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0])
2024-09-05 19:49:30 DEBUG Starting new HTTPS connection (3): fc.yahoo.com:443
2024-09-05 19:49:31 ERROR $^NSEI: possibly delisted; no price data found  (period=1d)
2024-09-05 19:49:31 DEBUG Exiting history()
2024-09-05 19:49:31 DEBUG Entering history()
2024-09-05 19:49:31 DEBUG  Entering history()
2024-09-05 19:49:31 DEBUG ^NSEI: Yahoo GET parameters: {'range': '1y', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
2024-09-05 19:49:31 DEBUG   Entering get()
2024-09-05 19:49:31 DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/^NSEI
2024-09-05 19:49:31 DEBUG params={'range': '1y', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
2024-09-05 19:49:31 DEBUG    Entering _get_cookie_and_crumb()
2024-09-05 19:49:31 DEBUG cookie_mode = 'basic'
2024-09-05 19:49:31 DEBUG     Entering _get_cookie_and_crumb_basic()
2024-09-05 19:49:31 DEBUG ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0])
2024-09-05 19:49:31 DEBUG Starting new HTTPS connection (4): fc.yahoo.com:443
2024-09-05 19:49:31 ERROR $^NSEI: possibly delisted; no price data found  (period=1y)
2024-09-05 19:49:31 DEBUG  Exiting history()
2024-09-05 19:49:31 DEBUG Exiting history()
2024-09-05 19:49:31 DEBUG get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary/^BSESN
2024-09-05 19:49:31 DEBUG Entering get()
2024-09-05 19:49:31 DEBUG url=https://query2.finance.yahoo.com/v10/finance/quoteSummary/^BSESN
2024-09-05 19:49:31 DEBUG params={'modules': 'financialData,quoteType,defaultKeyStatistics,assetProfile,summaryDetail', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false', 'symbol': '^BSESN'}
2024-09-05 19:49:31 DEBUG  Entering _get_cookie_and_crumb()
2024-09-05 19:49:31 DEBUG cookie_mode = 'basic'
2024-09-05 19:49:31 DEBUG   Entering _get_cookie_and_crumb_basic()
2024-09-05 19:49:31 DEBUG ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0])
2024-09-05 19:49:31 DEBUG Starting new HTTPS connection (5): fc.yahoo.com:443
2024-09-05 19:49:31 DEBUG ('SELECT "t1"."key", "t1"."value" FROM "_kv" AS "t1" WHERE ("t1"."key" = ?) LIMIT ? OFFSET ?', ['^BSESN', 1, 0])
2024-09-05 19:49:31 DEBUG Entering _fetch_ticker_tz()
2024-09-05 19:49:31 DEBUG  Entering get()
2024-09-05 19:49:31 DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/^BSESN
2024-09-05 19:49:31 DEBUG params=frozendict.frozendict({'range': '1d', 'interval': '1d'})
2024-09-05 19:49:31 DEBUG   Entering _get_cookie_and_crumb()
2024-09-05 19:49:31 DEBUG cookie_mode = 'basic'
2024-09-05 19:49:31 DEBUG    Entering _get_cookie_and_crumb_basic()
2024-09-05 19:49:31 DEBUG ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0])
2024-09-05 19:49:31 DEBUG Starting new HTTPS connection (6): fc.yahoo.com:443
2024-09-05 19:49:31 ERROR Failed to get ticker '^BSESN' reason: HTTPSConnectionPool(host='fc.yahoo.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x77607dd20da0>: Failed to establish a new connection: [Errno 111] Connection refused'))
2024-09-05 19:49:31 DEBUG Exiting _fetch_ticker_tz()
2024-09-05 19:49:31 DEBUG Entering history()
2024-09-05 19:49:31 DEBUG ^BSESN: Yahoo GET parameters: {'range': '1d', 'interval': '1d', 'includePrePost': True, 'events': 'div,splits,capitalGains'}
2024-09-05 19:49:31 DEBUG  Entering get()
2024-09-05 19:49:31 DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/^BSESN
2024-09-05 19:49:31 DEBUG params={'range': '1d', 'interval': '1d', 'includePrePost': True, 'events': 'div,splits,capitalGains'}
2024-09-05 19:49:31 DEBUG   Entering _get_cookie_and_crumb()
2024-09-05 19:49:31 DEBUG cookie_mode = 'basic'
2024-09-05 19:49:31 DEBUG    Entering _get_cookie_and_crumb_basic()
2024-09-05 19:49:31 DEBUG ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0])
2024-09-05 19:49:31 DEBUG Starting new HTTPS connection (7): fc.yahoo.com:443
2024-09-05 19:49:31 ERROR $^BSESN: possibly delisted; no price data found  (period=1d)
2024-09-05 19:49:31 DEBUG Exiting history()
2024-09-05 19:49:31 DEBUG Entering history()
2024-09-05 19:49:31 DEBUG  Entering history()
2024-09-05 19:49:31 DEBUG ^BSESN: Yahoo GET parameters: {'range': '1y', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
2024-09-05 19:49:31 DEBUG   Entering get()
2024-09-05 19:49:31 DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/^BSESN
2024-09-05 19:49:31 DEBUG params={'range': '1y', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
2024-09-05 19:49:31 DEBUG    Entering _get_cookie_and_crumb()
2024-09-05 19:49:31 DEBUG cookie_mode = 'basic'
2024-09-05 19:49:31 DEBUG     Entering _get_cookie_and_crumb_basic()
2024-09-05 19:49:31 DEBUG ('SELECT "t1"."strategy", "t1"."fetch_date", "t1"."cookie_bytes" FROM "_cookieschema" AS "t1" WHERE ("t1"."strategy" = ?) LIMIT ? OFFSET ?', ['basic', 1, 0])
2024-09-05 19:49:31 DEBUG Starting new HTTPS connection (8): fc.yahoo.com:443
2024-09-05 19:49:31 ERROR $^BSESN: possibly delisted; no price data found  (period=1y)
2024-09-05 19:49:31 DEBUG  Exiting history()
2024-09-05 19:49:31 DEBUG Exiting history()
collecting 189 items                                                                                                                                                                                                2024-09-05 19:49:31 DEBUG Initializing backend: None results/PKDevTools_cache
2024-09-05 19:49:31 DEBUG Initialized SQLiteDict with serializer: SerializerPipeline(name=pickle, n_stages=2)
2024-09-05 19:49:31 DEBUG Opening connection to /home/hextron/project/pkscreen/PKScreener/test/results/PKDevTools_cache.sqlite:responses
2024-09-05 19:49:31 DEBUG Initialized SQLiteDict with serializer: None
2024-09-05 19:49:31 DEBUG Opening connection to /home/hextron/project/pkscreen/PKScreener/test/results/PKDevTools_cache.sqlite:redirects
collected 512 items / 1 error                                                  

==================================== ERRORS ====================================
____________________ ERROR collecting pkscreenercli_test.py ____________________
ImportError while importing test module '/home/hextron/project/pkscreen/PKScreener/test/pkscreenercli_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
pkscreenercli_test.py:36: in <module>
    from pkscreener.globals import shutdown
E   ImportError: cannot import name 'shutdown' from 'pkscreener.globals' (/home/hextron/project/pkscreen/lib/python3.12/site-packages/pkscreener-0.45.20240905.546-py3.12.egg/pkscreener/globals.py)
=========================== short test summary info ============================
ERROR pkscreenercli_test.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 4.42s ===============================
Redbro1 commented 2 months ago

Solution: This error can be address ta-lib, distutils, setuptools https://github.com/TA-Lib/ta-lib-python Current Version is Python 3.11 my was 3.12.5 as shown so may be downgrade for now.