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

[Bug] NoneType error when trying to import obb from OpenBB #6942

Open
Chidifinance opened this issue Nov 8, 2024 · 9 comments
Open

[Bug] NoneType error when trying to import obb from OpenBB #6942

Chidifinance opened this issue Nov 8, 2024 · 9 comments

Comments

@Chidifinance
Copy link

Describe the bug
It's as description says, when I try to import obb from openbb I get

TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

To Reproduce
Only one step

from openbb import obb

Screenshots
image

Desktop (please complete the following information):

  • OS: Sonoma 14.5
  • Python version 3.11.10

Additional context

Full Error output:
{
"name": "TypeError",
"message": "stat: path should be string, bytes, os.PathLike or integer, not NoneType",
"stack": "---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[8], line 1
----> 1 from openbb import obb

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb/init.py:8
5 from pathlib import Path
6 from typing import List, Optional, Union
----> 8 from openbb_core.app.static.app_factory import (
9 BaseApp as _BaseApp,
10 create_app as _create_app,
11 )
12 from openbb_core.app.static.package_builder import PackageBuilder as _PackageBuilder
13 from openbb_core.app.static.reference_loader import ReferenceLoader as _ReferenceLoader

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/static/app_factory.py:7
5 from openbb_core.app.command_runner import CommandRunner
6 from openbb_core.app.model.system_settings import SystemSettings
----> 7 from openbb_core.app.model.user_settings import UserSettings
8 from openbb_core.app.static.account import Account
9 from openbb_core.app.static.container import Container

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/model/user_settings.py:6
3 from pydantic import Field
5 from openbb_core.app.model.abstract.tagged import Tagged
----> 6 from openbb_core.app.model.credentials import Credentials
7 from openbb_core.app.model.defaults import Defaults
8 from openbb_core.app.model.preferences import Preferences

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/model/credentials.py:98
94 model.origins = self.credentials
95 return model
---> 98 _Credentials = CredentialsLoader().load()
101 class Credentials(_Credentials): # type: ignore
102 """Credentials model used to store provider credentials."""

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/model/credentials.py:87, in CredentialsLoader.load(self)
85 """Load credentials from providers."""
86 # We load providers first to give them priority choosing credential names
---> 87 self.from_providers()
88 self.from_obbject()
89 model = create_model(
90 "Credentials",
91 config=ConfigDict(validate_assignment=True, populate_by_name=True),
92 **self.format_credentials(), # type: ignore
93 )

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/model/credentials.py:82, in CredentialsLoader.from_providers(self)
80 def from_providers(self) -> None:
81 """Load credentials from providers."""
---> 82 self.credentials = ProviderInterface().credentials

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/model/abstract/singleton.py:17, in SingletonMeta.call(cls, *args, **kwargs)
15 """Singleton pattern implementation."""
16 if cls not in cls._instances:
---> 17 instance = super().call(*args, **kwargs)
18 cls._instances[cls] = instance
20 return cls._instances[cls]

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/provider_interface.py:107, in ProviderInterface.init(self, registry_map, query_executor)
101 def init(
102 self,
103 registry_map: Optional[RegistryMap] = None,
104 query_executor: Optional[QueryExecutor] = None,
105 ) -> None:
106 """Initialize provider interface."""
--> 107 self._registry_map = registry_map or RegistryMap()
108 self._query_executor = query_executor or QueryExecutor
110 self._map = self._registry_map.standard_extra

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/provider/registry_map.py:26, in RegistryMap.init(self, registry)
24 def init(self, registry: Optional[Registry] = None) -> None:
25 """Initialize Registry Map."""
---> 26 self._registry = registry or RegistryLoader.from_extensions()
27 self._credentials = self._get_credentials(self._registry)
28 self._available_providers = self._get_available_providers(self._registry)

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/provider/registry.py:44, in RegistryLoader.from_extensions()
41 """Load providers from entry points."""
42 registry = Registry()
---> 44 for name, entry in ExtensionLoader().provider_objects.items(): # type: ignore[attr-defined]
45 try:
46 registry.include_provider(provider=entry)

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/model/abstract/singleton.py:17, in SingletonMeta.call(cls, *args, **kwargs)
15 """Singleton pattern implementation."""
16 if cls not in cls._instances:
---> 17 instance = super().call(*args, **kwargs)
18 cls._instances[cls] = instance
20 return cls._instances[cls]

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/extension_loader.py:41, in ExtensionLoader.init(self)
37 def init(
38 self,
39 ) -> None:
40 """Initialize the extension loader."""
---> 41 self._obbject_entry_points: EntryPoints = self._sorted_entry_points(
42 group=OpenBBGroups.obbject.value
43 )
44 self._core_entry_points: EntryPoints = self._sorted_entry_points(
45 group=OpenBBGroups.core.value
46 )
47 self._provider_entry_points: EntryPoints = self._sorted_entry_points(
48 group=OpenBBGroups.provider.value
49 )

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/openbb_core/app/extension_loader.py:127, in ExtensionLoader._sorted_entry_points(group)
124 @staticmethod
125 def _sorted_entry_points(group: str) -> EntryPoints:
126 """Return a sorted dictionary of entry points."""
--> 127 return sorted(entry_points(group=group))

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/importlib_metadata/init.py:1051, in entry_points(**params)
1040 """Return EntryPoint objects for all installed packages.
1041
1042 Pass selection parameters (group or name) to filter the
(...)
1046 :return: EntryPoints for all installed packages.
1047 """
1048 eps = itertools.chain.from_iterable(
1049 dist.entry_points for dist in _unique(distributions())
1050 )
-> 1051 return EntryPoints(eps).select(**params)

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/importlib_metadata/init.py:1048, in (.0)
1039 def entry_points(**params) -> EntryPoints:
1040 """Return EntryPoint objects for all installed packages.
1041
1042 Pass selection parameters (group or name) to filter the
(...)
1046 :return: EntryPoints for all installed packages.
1047 """
-> 1048 eps = itertools.chain.from_iterable(
1049 dist.entry_points for dist in _unique(distributions())
1050 )
1051 return EntryPoints(eps).select(**params)

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/importlib_metadata/_itertools.py:16, in unique_everseen(iterable, key)
14 yield element
15 else:
---> 16 for element in iterable:
17 k = key(element)
18 if k not in seen:

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/importlib_metadata/init.py:931, in (.0)
928 """Find metadata directories in paths heuristically."""
929 prepared = Prepared(name)
930 return itertools.chain.from_iterable(
--> 931 path.search(prepared) for path in map(FastPath, paths)
932 )

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/importlib_metadata/init.py:790, in FastPath.search(self, name)
789 def search(self, name):
--> 790 return self.lookup(self.mtime).search(name)

File ~/miniconda3/envs/openbb/lib/python3.11/site-packages/importlib_metadata/init.py:795, in FastPath.mtime(self)
792 @Property
793 def mtime(self):
794 with suppress(OSError):
--> 795 return os.stat(self.root).st_mtime
796 self.lookup.cache_clear()

TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType"
}

@Chidifinance
Copy link
Author

I found a work around for now. For some reason, it seems like the extension loader pkg is loading en variables & including None in the list of paths passed to importlib.

I added a line to take out the ones that wont work in importlib

@deeleeramone
Copy link
Contributor

deeleeramone commented Nov 9, 2024

Hmm.. I'm not able to reproduce. What versions do you have installed?

Sonoma 14.6.1

conda 24.9.1

importlib_metadata      8.5.0
openbb                  4.3.4
pip                     24.3.1

@deeleeramone
Copy link
Contributor

What are the exact steps in recreating your complete environment?

@piiq
Copy link
Contributor

piiq commented Nov 11, 2024

@Chidifinance from the error log I assume that it starts failing when importing your user settings. Can you look into the ~/.openbb_platform folder and show the contents of your user_settings.json? You will need to remove the credentials before sharing

@piiq
Copy link
Contributor

piiq commented Nov 11, 2024

Also an output of pip listwould be helpful

@Chidifinance
Copy link
Author

Hmm.. I'm not able to reproduce. What versions do you have installed?

Sonoma 14.6.1

conda 24.9.1

importlib_metadata      8.5.0
openbb                  4.3.4
pip                     24.3.1

Version of what?

@Chidifinance
Copy link
Author

@Chidifinance from the error log I assume that it starts failing when importing your user settings. Can you look into the ~/.openbb_platform folder and show the contents of your user_settings.json? You will need to remove the credentials before sharing

{
"credentials": {},
"preferences": {},
"defaults": {
"commands": {}
}
}

This is what i see in the file. Moreover, something I noticed in the error is that it might be somehow loading my environ file. Cause the issue originates from when importlib is trying to find packages from paths. These paths are gotten from openbb somehow. Checking the paths holder which is a lost, I saw environ type & nonetype which shouldn't be there

@Chidifinance
Copy link
Author

What are the exact steps in recreating your complete environment?

Literally just importing it. It's quite unstable so I really dunno how to produce it consistently. Idk if load_dotenv may be affecting it?

@Chidifinance
Copy link
Author

Also an output of pip listwould be helpful

Package Version


aiofiles 22.1.0
aiohappyeyeballs 2.4.0
aiohttp 3.10.5
aiohttp-client-cache 0.11.1
aiosignal 1.3.1
aiosqlite 0.20.0
annotated-types 0.7.0
anyio 3.5.0
appdirs 1.4.4
appnope 0.1.2
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
asttokens 2.0.5
attrs 23.2.0
Babel 2.11.0
backcall 0.2.0
backoff 2.2.1
Backtesting 0.3.3
backtrader 1.9.76.123
beautifulsoup4 4.12.2
bleach 4.1.0
bokeh 3.4.1
Bottleneck 1.3.5
brotlipy 0.7.0
bs4 0.0.2
bt 0.2.9
btplotting 0.2.1
build 1.2.1
CacheControl 0.14.0
cattrs 23.2.3
certifi 2023.7.22
cffi 1.17.0
charset-normalizer 2.0.4
cleo 2.1.0
click 8.1.7
comm 0.2.2
contourpy 1.2.1
crashtest 0.4.1
cryptography 41.0.2
cycler 0.11.0
dateparser 1.2.0
debugpy 1.6.7
decorator 5.1.1
defusedxml 0.8.0rc2
dill 0.3.8
distlib 0.3.8
dnspython 2.6.1
dulwich 0.21.7
email_validator 2.2.0
entrypoints 0.4
et-xmlfile 1.1.0
executing 0.8.3
fastapi 0.111.1
fastapi-cli 0.0.5
fastjsonschema 2.20.0
ffn 0.3.7
filelock 3.15.4
fonttools 4.42.0
frozendict 2.3.8
frozenlist 1.4.1
future 0.18.3
greenlet 3.0.3
h11 0.14.0
html5lib 1.1
httpcore 1.0.5
httptools 0.6.1
httpx 0.27.0
idna 3.4
imageio 2.34.1
import-ipynb 0.1.4
importlib-metadata 6.11.0
installer 0.7.0
ipykernel 6.29.4
ipython 8.12.2
ipython-genutils 0.2.0
ipywidgets 8.1.3
itsdangerous 2.2.0
jaraco.classes 3.4.0
jedi 0.18.1
Jinja2 3.1.2
joblib 1.3.2
json5 0.9.6
jsonschema 4.17.3
jupyter_client 7.4.9
jupyter_core 5.3.0
jupyter-events 0.6.3
jupyter-server 1.23.4
jupyter_server_fileid 0.9.0
jupyter_server_ydoc 0.8.0
jupyter-ydoc 0.2.4
jupyterlab 3.6.3
jupyterlab-pygments 0.1.2
jupyterlab_server 2.22.0
jupyterlab_widgets 3.0.11
kaleido 0.2.1
keyring 24.3.1
kiwisolver 1.4.4
llvmlite 0.43.0
loguru 0.7.2
lxml 5.3.0
markdown-it-py 3.0.0
markdown2 2.4.13
MarkupSafe 2.1.1
matplotlib 3.2.2
matplotlib-inline 0.1.6
mdurl 0.1.2
mistune 0.8.4
mkl-fft 1.3.6
mkl-random 1.2.2
mkl-service 2.4.0
monotonic 1.6
more-itertools 10.4.0
mpld3 0.5.10
mplfinance 0.12.10b0
msgpack 1.0.8
multidict 6.0.5
multiprocess 0.70.16
multitasking 0.0.9
munkres 1.1.4
mypy-extensions 1.0.0
mysql-connector-python 9.0.0
nbclassic 0.5.5
nbclient 0.5.13
nbconvert 6.5.4
nbformat 5.7.0
ndg-httpsclient 0.5.1
nest-asyncio 1.5.6
notebook 6.5.4
notebook_shim 0.2.2
numba 0.60.0
numexpr 2.8.4
numpy 1.25.2
oath 1.4.4
openbb 4.3.1
openbb-benzinga 1.3.1
openbb-commodity 1.2.1
openbb-core 1.3.1
openbb-crypto 1.3.1
openbb-currency 1.3.1
openbb-derivatives 1.3.1
openbb-econdb 1.2.1
openbb-economy 1.3.1
openbb-equity 1.3.1
openbb-etf 1.3.1
openbb-federal-reserve 1.3.1
openbb-fixedincome 1.3.1
openbb-fmp 1.3.1
openbb-fred 1.3.1
openbb-index 1.3.1
openbb-intrinio 1.3.1
openbb-news 1.3.1
openbb-oecd 1.3.1
openbb-polygon 1.3.1
openbb-regulators 1.3.1
openbb-sec 1.3.1
openbb-tiingo 1.3.1
openbb-tradingeconomics 1.3.1
openbb-yfinance 1.3.1
openpyxl 3.1.2
optopsy 2.0.1
outcome 1.3.0.post0
packaging 24.1
pandas 2.2.2
pandas-datareader 0.10.0
pandas-ta 0.3.14b0
pandocfilters 1.5.0
parso 0.8.3
pathos 0.3.2
peewee 3.17.6
pexpect 4.8.0
pickleshare 0.7.5
Pillow 9.4.0
pip 23.2.1
pkginfo 1.11.1
platformdirs 4.2.2
playwright 1.45.0
playwright-stealth 1.0.6
plotly 5.18.0
poetry 1.8.3
poetry-core 1.9.0
poetry-plugin-export 1.8.0
polygon-api-client 1.12.3
posthog 3.5.2
pox 0.3.4
ppft 1.7.6.8
prometheus-client 0.14.1
prompt-toolkit 3.0.36
psutil 5.9.0
ptyprocess 0.7.0
pure-eval 0.2.2
py-lets-be-rational 1.0.1
py-vollib 1.0.1
pyaml 24.4.0
pyasn1 0.4.8
pycparser 2.21
pycryptodome 3.20.0
pydantic 2.8.2
pydantic_core 2.20.1
pyee 11.1.0
Pygments 2.15.1
PyJWT 2.9.0
pyOpenSSL 23.2.0
pyotp 2.9.0
pyparsing 3.1.1
PyPrind 2.11.2
pyproject_hooks 1.1.0
pyrsistent 0.18.0
PySocks 1.7.1
python-dateutil 2.8.2
python-decouple 3.8
python-dotenv 1.0.0
python-json-logger 2.0.7
python-multipart 0.0.7
python-vipaccess 0.14.2
pytz 2022.7
PyYAML 6.0
pyzmq 26.0.3
rapidfuzz 3.9.6
regex 2024.5.15
requests 2.32.3
requests-cache 1.2.1
requests-toolbelt 1.0.0
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rich 13.7.1
robin-stocks 3.0.6
ruff 0.6.2
schedule 1.2.2
schwab-api 0.3.0
schwabdev 2.0.1
scikit-learn 1.2.2
scikit-optimize 0.10.2
scipy 1.11.1
seaborn 0.13.2
selenium 4.22.0
Send2Trash 1.8.0
setuptools 68.0.0
shellingham 1.5.4
simplejson 3.19.2
six 1.16.0
sniffio 1.3.1
sortedcontainers 2.4.0
soupsieve 2.4
stack-data 0.2.0
starlette 0.37.2
ta 0.11.0
TA-Lib 0.4.28
tabulate 0.9.0
tenacity 8.2.3
terminado 0.17.1
threadpoolctl 3.2.0
tinycss2 1.2.1
toml 0.10.2
tomlkit 0.13.2
tornado 6.3.2
tqdm 4.66.4
tradingpattern 0.0.5
traitlets 5.7.1
trio 0.26.0
trio-websocket 0.11.1
trove-classifiers 2024.7.2
typer 0.12.4
types-urllib3 1.26.25.13
typing_extensions 4.12.2
tzdata 2024.1
tzlocal 5.2
url-normalize 1.4.3
urllib3 2.2.2
uuid7 0.1.0
uvicorn 0.24.0.post1
uvloop 0.20.0
vectorbt 0.26.1
virtualenv 20.26.3
watchfiles 0.23.0
wcwidth 0.2.5
webencodings 0.5.1
websocket-client 1.8.0
websockets 12.0
wheel 0.38.4
widgetsnbextension 4.0.11
wikipedia 1.4.0
wsproto 1.2.0
xattr 1.1.0
XlsxWriter 3.1.2
xmltodict 0.13.0
xyzservices 2024.6.0
y-py 0.5.9
yarl 1.9.4
yfinance 0.2.42
ypy-websocket 0.8.2
zipp 3.20.0

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

3 participants