OpenBB-finance / OpenBB

Investment Research for Everyone, Everywhere.
https://openbb.co
Other
30.21k stars 2.81k forks source link

[Bug] Installation via source on Windows - ImportError: DLL load failed while importing _ctypes: The specified module could not be found. #4639

Closed ghbcode closed 3 months ago

ghbcode commented 1 year ago

Describe the bug Clean OpenTerminal installation on Windows 10 per source install instructions fails at the step

pip install qdldl==0.1.5.post3

The error is:

  File "C:\Users\admin\.conda\envs\obb2\lib\ctypes\__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ImportError: DLL load failed while importing _ctypes: The specified module could not be found.

To Reproduce Using Windows 10 (10.0.19041.2728) installed

run miniconda prompt so (base) env is activated

conda create -n obb2 -c conda-forge python=3.10.9 pip pybind11 cmake git cvxpy lightgbm poetry
conda activate obb2
git clone https://github.com/OpenBB-finance/OpenBBTerminal.git
cd OpenBBTerminal
pip install qdldl==0.1.5.post3

I get the error:

(obb2) C:\Users\admin\OpenBBTerminal>pip install qdldl==0.1.5.post3
Traceback (most recent call last):
  File "C:\Users\admin\.conda\envs\obb2\Scripts\pip-script.py", line 5, in <module>
    from pip._internal.cli.main import main
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\cli\main_parser.py", line 9, in <module>
    from pip._internal.build_env import get_runnable_pip
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\build_env.py", line 19, in <module>
    from pip._internal.cli.spinners import open_spinner
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\cli\spinners.py", line 9, in <module>
    from pip._internal.utils.logging import get_indentation
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\utils\logging.py", line 29, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\utils\misc.py", line 43, in <module>
    from pip._internal.locations import get_major_minor_version
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\locations\__init__.py", line 14, in <module>
    from . import _sysconfig
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\locations\_sysconfig.py", line 11, in <module>
    from .base import change_root, get_major_minor_version, is_osx_framework
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\locations\base.py", line 9, in <module>
    from pip._internal.utils import appdirs
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_internal\utils\appdirs.py", line 13, in <module>
    from pip._vendor import platformdirs as _appdirs
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 44, in <module>
    PlatformDirs = _set_platform_dir_class()  #: Currently active platform
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 23, in _set_platform_dir_class
    from pip._vendor.platformdirs.windows import Windows as Result
  File "C:\Users\admin\.conda\envs\obb2\lib\site-packages\pip\_vendor\platformdirs\windows.py", line 3, in <module>
    import ctypes
  File "C:\Users\admin\.conda\envs\obb2\lib\ctypes\__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ImportError: DLL load failed while importing _ctypes: The specified module could not be found.

Screenshots ctypes import error

Desktop (please complete the following information):

Additional context I did NOT install any other packages like apparently was done in ticket 4591. I followed the steps in the source install page. I've also, removed minconda, removed the .conda folder, OpenTerminal folder, restarted windows and re-installed (using obb2 as the env) everything from scratch. Same error.

ghbcode commented 1 year ago

Also, I forgot to mention that the link the troubleshooting page (https://docs.openbb.co/terminal/quickstart/troubleshooting) inside of the install from source page appears to be broken.

ghbcode commented 1 year ago

I tried the installation on a fresh PC and only modified one step along the way. Instead of installing miniconda3 I installed Anaconda3-2023.03-Windows-x86_64 as I recall getting this all to work using anaconda if I'm not mistaken. The error remains.

(obb) C:\Users\admin\OpenBBTerminal>pip install qdldl==0.1.5.post3
Traceback (most recent call last):
  File "C:\Users\admin\.conda\envs\obb\Scripts\pip-script.py", line 5, in <module>
    from pip._internal.cli.main import main
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\cli\main_parser.py", line 9, in <module>
    from pip._internal.build_env import get_runnable_pip
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\build_env.py", line 19, in <module>
    from pip._internal.cli.spinners import open_spinner
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\cli\spinners.py", line 9, in <module>
    from pip._internal.utils.logging import get_indentation
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\utils\logging.py", line 29, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\utils\misc.py", line 43, in <module>
    from pip._internal.locations import get_major_minor_version
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\locations\__init__.py", line 14, in <module>
    from . import _sysconfig
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\locations\_sysconfig.py", line 11, in <module>
    from .base import change_root, get_major_minor_version, is_osx_framework
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\locations\base.py", line 9, in <module>
    from pip._internal.utils import appdirs
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_internal\utils\appdirs.py", line 13, in <module>
    from pip._vendor import platformdirs as _appdirs
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 44, in <module>
    PlatformDirs = _set_platform_dir_class()  #: Currently active platform
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 23, in _set_platform_dir_class
    from pip._vendor.platformdirs.windows import Windows as Result
  File "C:\Users\admin\.conda\envs\obb\lib\site-packages\pip\_vendor\platformdirs\windows.py", line 3, in <module>
    import ctypes
  File "C:\Users\admin\.conda\envs\obb\lib\ctypes\__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ImportError: DLL load failed while importing _ctypes: The specified module could not be found.

(obb) C:\Users\admin\OpenBBTerminal>
deeleeramone commented 1 year ago

Try: pip install pywin32-ctypes

kovacsgyula commented 1 year ago

Try: pip install pywin32-ctypes

Giving the same error, File "C:\Anaconda\envs\obb\lib\ctypes\__init__.py", line 8, in <module> from _ctypes import Union, Structure, Array ImportError: DLL load failed while importing _ctypes: A megadott modul nem található.

deeleeramone commented 1 year ago

@kovacsgyula - try this one: conda install -c conda-forge libffi

@piiq any ideas here why this is happening for Windows users, seemingly all of a sudden?

deeleeramone commented 1 year ago

@ghbcode, @kovacsgyula

We have some new instructions that are still living on the development branch. Can you try following these?

https://github.com/OpenBB-finance/OpenBBTerminal/blob/develop/website/content/terminal/installation/pypi.md

ghbcode commented 1 year ago

I tried the instructions above with tentative success. I am able to run the terminal, I've defined a few keys and pulled up some information. Please bear with me on this question though is this installation supposed to put the source code somewhere for our use? I realize that the application and the SDK/API are working, but I'm looking to run the terminal from source code. I was able to do this a while ago on a different computer that has since been broken so I'm trying on a new machine. thank you for your time and help

ghbcode commented 1 year ago

As a side note I went ahead and did the following after installing per the instrux https://github.com/OpenBB-finance/OpenBBTerminal/blob/develop/website/content/terminal/installation/pypi.md:

  1. conda activate obb
  2. git clone https://github.com/OpenBB-finance/OpenBBTerminal.git
  3. cd OpenBBTerminal
  4. python terminal.py (got some module missing error)
  5. had to install these two modules (pip install reportlab, pip install svglib)
  6. python terminal.py (gives the following errors posted below but I am able to proceed to the terminal)

I was able to set the FRED key, ask "about fred" and query in economy/fred "fred -p T10Y2Y" and got a graph of the series. I cannot say for sure but the approach that I took may help someone with installing and running the source code in Windows if they encountered the error that some are experiencing. Still, it would be nice to have the official Source code install instructions work for Windows. The error below implies a Linux install, I am definitely on Windows 10...

(obb) d:\home\OpenBBTerminal>python terminal.py
←[91mNo module named 'pywry'←[0m
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000026121C4D670>
Traceback (most recent call last):
  File "C:\ProgramData\anaconda3\envs\obb\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\ProgramData\anaconda3\envs\obb\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\ProgramData\anaconda3\envs\obb\lib\asyncio\base_events.py", line 751, in call_soon
    self._check_closed()
  File "C:\ProgramData\anaconda3\envs\obb\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

PyWry is not installed or missing required linux dependencies.

Install PyWry
pip install pywry --upgrade

Platform-specific notes
Here is the underlying web engine each platform uses you might need to install.

Linux
Pywry uses gtk-rs and its related libraries for window creation and Wry also needs WebKitGTK for WebView.
To activate interactive plots/tables in pywry window, please make sure the following packages are installed:

Arch Linux / Manjaro:
sudo pacman -S webkit2gtk-4.0

Debian / Ubuntu:
sudo apt install libwebkit2gtk-4.0-dev

Fedora / CentOS / AlmaLinux:
sudo dnf install gtk3-devel webkit2gtk4.0-devel

If you prefer to continue without interactive plots/tables, press enter or ctrl+c to exit.

Welcome to OpenBB Terminal v3.0.0rc1
deeleeramone commented 1 year ago

Installing via a cloned repo is different than installing from PyPi, see the git clone instructions here: https://github.com/OpenBB-finance/OpenBBTerminal/blob/develop/website/content/terminal/installation/source.md