The alpha_vantage module is installed, but the ModuleNotFoundError
still occurs.
running on a virtual environment (venv).
The interpreter also uses ./.vevn/bin/python
from a virtual environment.
In addition, alpha-vantage
has been installed in a virtual environment.
$which python
/home/****/***/***/.venv/bin/python
$ which pip
/home/****/***/***/.venv/bin/pip
$ pip freeze | grep alpha
alpha-vantage==2.3.1
from alpha_vantage.timeseries import TimeSeries
from print import print
ts=TimeSeries(key='******', output_format='pandas')
data, meta_data=ts.get_intraday(symbol='MSFT', interval='1min', outputsize='full')
print(data.head(2))
python alpha_vantage.py
Traceback (most recent call last):
File"/home/***/***/***/alpha_vantage.py", line 1, in <module>
from alpha_vantage.timeseries import TimeSeries
File"/home/***/***/***/alpha_vantage.py", line 1, in <module>
from alpha_vantage.timeseries import TimeSeries
ModuleNotFoundError: No module named 'alpha_vantage.timeseries'; 'alpha_vantage' is not a package
Just in case, I installed and ran the alpha_vantage
module not only in the virtual environment but also in the main unit, and the result was also ModuleNotFoundError
.
Please let me know if there is a solution.
python python3
Self-resolved.
The file name you ran was the same as the module name.
Executable Name: alpha_vantage.py
Package you want to import: alpha_vantage
Rename the executable file.
alpha_vantage.py ->alp_vantage.py
Now the executable name is no longer the module name, and the package can be loaded successfully.
https://github.com/RomelTorres/alpha_vantage/issues/64#issuecomment-384323361
© 2025 OneMinuteCode. All rights reserved.