为什么 xgboost 工作/不工作取决于其他软件包的导入顺序?
当尝试使用以下命令导入 xgboost 时:
import pandas as pd, numpy as np, psycopg2, xgboost as xgb, os, shutil, pickle, random
我收到以下错误:
File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/__init__.py", line 9, in <module>
from .core import DMatrix, DeviceQuantileDMatrix, Booster, DataIter
File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/core.py", line 203, in <module>
_LIB = _load_lib()
File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/core.py", line 194, in _load_lib
""")
xgboost.core.XGBoostError:
XGBoost Library (libxgboost.so) could not be loaded.
Likely causes:
* OpenMP runtime is not installed
- vcomp140.dll or libgomp-1.dll for Windows
- libomp.dylib for Mac OSX
- libgomp.so for Linux and other UNIX-like OSes
Mac OSX users: Run `brew install libomp` to install OpenMP runtime.
* You are running 32-bit Python on a 64-bit OS
Error message(s): ['dlopen: cannot load any more object with static TLS']
在 psycopg2 前面切换 xgboost 的导入,如下所示:
import pandas as pd, numpy as np, xgboost as xgb, psycopg2, os, shutil, pickle, random
代码导入,找到共享库并运行良好。
我知道这可能取决于服务器/环境的设置,但是首先导入 xgboost 时它的工作是否有某种原因? psycopg2 是否可能更改系统路径或环境变量?
干杯
When trying to import xgboost with the following:
import pandas as pd, numpy as np, psycopg2, xgboost as xgb, os, shutil, pickle, random
I get the following error:
File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/__init__.py", line 9, in <module>
from .core import DMatrix, DeviceQuantileDMatrix, Booster, DataIter
File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/core.py", line 203, in <module>
_LIB = _load_lib()
File "/opt/virtual_environments/ml_venv/lib/python3.6/site-packages/xgboost/core.py", line 194, in _load_lib
""")
xgboost.core.XGBoostError:
XGBoost Library (libxgboost.so) could not be loaded.
Likely causes:
* OpenMP runtime is not installed
- vcomp140.dll or libgomp-1.dll for Windows
- libomp.dylib for Mac OSX
- libgomp.so for Linux and other UNIX-like OSes
Mac OSX users: Run `brew install libomp` to install OpenMP runtime.
* You are running 32-bit Python on a 64-bit OS
Error message(s): ['dlopen: cannot load any more object with static TLS']
Switching the import of xgboost in front of psycopg2 like so:
import pandas as pd, numpy as np, xgboost as xgb, psycopg2, os, shutil, pickle, random
The code imports, finds the shared libraries and runs fine.
I know this could be dependent on the setup of the server/environment, but is there some reason why its working when xgboost is imported first? Is psycopg2 potentially changing system paths or environment variables?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论