🌐
Stack Overflow
stackoverflow.com › questions › 67955692 › python3-module-not-found-error-after-installation-with-pip3
python - Python3 module not found error after installation with pip3 - Stack Overflow
After Guo Lei’s comment, I tried ... eventually told me what exactly happened: a module named int-date, required by stockstats, was not installed in the python library directory....
🌐
RoseIndia
roseindia.net › answers › viewqa › pythonquestions › 229478-ModuleNotFoundError-No-module-named-stockstats.html
ModuleNotFoundError: No module named 'stockstats'
After the installation of stockstats python library, ModuleNotFoundError: No module named 'stockstats' error will be solved.
🌐
GitHub
github.com › saeed349 › Deep-Reinforcement-Learning-in-Trading › issues › 1
No module named 'stockstats' · Issue #1 · saeed349/Deep-Reinforcement-Learning-in-Trading
October 26, 2018 - No module named 'stockstats'#1 · Copy link · chongyang915 · opened · on Oct 26, 2018 · Issue body actions · if you miss this ? No one assigned · No labels · No labels · No projects · No milestone · None yet · No branches or pull requests ·
Author   chongyang915
🌐
GitHub
github.com › jealous › stockstats › issues › 24
How to install / setup up stockstats · Issue #24 · jealous/stockstats
January 18, 2018 - Hey, Wondering if somebody could help a guy out in getting this installed and setup up to use? I'm pretty new at this so any advice would be wonderful. I have python installed, downloaded the files and I researched that I can get the "pa...
Author   toxilate
🌐
PyPI
pypi.org › project › stockstats
stockstats · PyPI
February 16, 2026 - If you're not sure about the file name format, learn more about wheel file names. ... Details for the file stockstats-0.6.8.tar.gz.
      » pip install stockstats
    
Published   Feb 16, 2026
Version   0.6.8
🌐
Copypaste
copypaste.guru › WhereIsMyPythonModule › how-to-fix-modulenotfounderror-no-module-named-stockstats
🤔 How to fix "ModuleNotFoundError: No module named 'stockstats'"
July 20, 2022 - Where is my Python module's answer to the question "How to fix "ModuleNotFoundError: No module named 'stockstats'""
🌐
freeCodeCamp
freecodecamp.org › news › module-not-found-error-in-python-solved
ModuleNotFoundError: no module named Python Error [Fixed]
September 12, 2022 - For resolving an imported module, Python checks places like the inbuilt library, installed modules, and modules in the current project. If it's unable to resolve that module, it throws the ModuleNotFoundError.
🌐
Stack Overflow
stackoverflow.com › questions › 66677034 › modulenotfounderror-no-module-named-stock
python - ModuleNotFoundError: No module named 'stock' - Stack Overflow
admin@XXXXXX:~$ source venv/bin/activate (venv) admin@XXXXXX:~$ export PATH="$HOME/.local/bin:$PATH" (venv) admin@XXXXXX:~$ export JUPYTER_RUNTIME_DIR=/tmp (venv) admin@XXXXXX:~$ python3 /volume1/homes/admin/Drive/stock/pri/get_pricetarget.py Traceback (most recent call last): File "/volume1/homes/admin/Drive/stock/pri/get_pricetarget.py", line 1, in <module> import stock as stock ModuleNotFoundError: No module named 'stock' (venv) admin@XXXXXX:~$
Find elsewhere
🌐
Towards Data Science
towardsdatascience.com › home › latest › how to fix modulenotfounderror and importerror
How to Fix ModuleNotFoundError and ImportError | Towards Data Science
January 21, 2025 - Recall that when you call import a if the module’s name was found neither in sys.modules nor in standard library, Python will try to resolve it in sys.path . Likewise, when you use from syntax (e.g. from mypackage import a ), Python will first attempt to find and load the module. When it fails to do so, Python will throw ModuleNotFoundError for the first case or ImportError for the second case.
Top answer
1 of 2
8

I got this error out of the box with Anaconda 4.4:

>>> import pandas.io.data
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.6/site-packages/pandas/io/data.py", line 2, in <module>
    "The pandas.io.data module is moved to a separate package "
ImportError: The pandas.io.data module is moved to a separate package (pandas-datareader). After installing the pandas-datareader package (https://github.com/pydata/pandas-datareader), you can change the import ``from pandas.io import data, wb`` to ``from pandas_datareader import data, wb``.

The error message is pretty nice. It recommends you go install pandas-datareader from https://github.com/pydata/pandas-datareader. Then change your import to from pandas_datareader import data.

Or you can just pip install pandas-datareader.

After that, from pandas_datareader import data works as expected:

Matthews-MacBook-Pro:python matt$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pandas_datareader import data
>>>
2 of 2
0

The sub-package pandas.io.data was deprecated in v.0.17 and removed in v.0.19. Instead there has been created a separately installable pandas-datareader package. This will allow the data modules to be independently updated on your pandas installation.

Installing

To install required packages through pip :

pip install pandas-datareader
OR
pip install git+https://github.com/pydata/pandas-datareader.git

Testing

from pandas_datareader import data
df=data.DataReader('AAPL','yahoo','2016/1/1','2017/1/1')
df.head()

Resources

  • pandas-datareader

  • Remote Data Access

Top answer
1 of 8
35

Your PYTHONPATH is set to the parent directory of the executed script. So if the executed script is inside a directory src, it will never be able to find the sister directory lib because it isn't within the path. There's a few choices;

  • Just move lib/ into src/ if it belongs to your code. If it's an external package, it should be pip installed.
  • Have a top-level script outside of src/ that imports and runs src.main. This will add the top-level directory to python path.
  • In src/main.py modify sys.path to include the top-level directory. This is usually frowned upon.
  • Invoke src/main.py as a module with python -m src.main which will add the top-level directory to the python path. Kind of annoying to type, plus you'll need to change all your imports.
2 of 8
12

If I may add to MarkM's answer, if you wanted to keep your current directory structure and still make it work, you could add a setup.py in your root directory, where you can use setuptools to create a package you could install.

If your file had something along the lines of:

# setup.py

from setuptools import find_packages, setup

setup(
  name='foo',
  version=`1.0.0`,
  packages=find_packages(),
  entrypoints={
    'console_scripts': [
      'foo=src.main:main',
    ],
  },
)

And then you do pip install [--user] -e path/to/directory you'll get an "editable package" which will effectively a symbolic link to the package in your development directory, so any changes you make will not require a reinstall (unless of course you rejig package structure or add/remove/edit entry points).

This does assume your src/main.py has a main function.

You'll also need __init__.py files in your "package" directories, even in Python 3, as otherwise Python assumes these are namespace packages (I won't go into detail) and the find_packages() call won't find them.

This will also allow your relative imports to work. Absolute imports will only work when invoking the script from your entry point, but not when calling the script directly in your development directory.

🌐
Finxter
blog.finxter.com › fixed-modulenotfounderror-no-module-named-statistics
[Fixed] ModuleNotFoundError: No module named ‘statistics’ – Be on the Right Side of Change
August 21, 2023 - This is supposed to import the statistics library into your (virtual) environment. However, it only throws the following ImportError: No module named statistics: >>> import statistics Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> import statistics ModuleNotFoundError: ...
Top answer
1 of 16
327

Based on your comments to orip's post, I guess this is what happened:

  1. You edited __init__.py on windows.
  2. The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).
  3. You used WinSCP to copy the file to your unix box.
  4. WinSCP thought: "This has something that's not basic text; I'll put a .bin extension to indicate binary data."
  5. The missing __init__.py (now called __init__.py.bin) means python doesn't understand toolkit as a package.
  6. You create __init__.py in the appropriate directory and everything works... ?
2 of 16
116

I ran into something very similar when I did this exercise in LPTHW; I could never get Python to recognise that I had files in the directory I was calling from. But I was able to get it to work in the end. What I did, and what I recommend, is to try this:

(NOTE: From your initial post, I am assuming you are using an *NIX-based machine and are running things from the command line, so this advice is tailored to that. Since I run Ubuntu, this is what I did)

  1. Change directory (cd) to the directory above the directory where your files are. In this case, you're trying to run the mountain.py file, and trying to call the toolkit.interface.py module, which are in separate directories. In this case, you would go to the directory that contains paths to both those files (or in other words, the closest directory that the paths of both those files share). Which in this case is the toolkit directory.

  2. When you are in the toolkit directory, enter this line of code on your command line:

    export PYTHONPATH=.

    This sets your PYTHONPATH to ".", which basically means that your PYTHONPATH will now look for any called files within the directory you are currently in, (and more to the point, in the sub-directory branches of the directory you are in. So it doesn't just look in your current directory, but in all the directories that are in your current directory).

  3. After you've set your PYTHONPATH in the step above, run your module from your current directory (the toolkit directory). Python should now find and load the modules you specified.

🌐
Finxter
blog.finxter.com › fixed-modulenotfounderror-no-module-named-statsmodels
[Fixed] ModuleNotFoundError: No module named ‘statsmodels’ – Be on the Right Side of Change
August 21, 2023 - This is supposed to import the ... the following ImportError: No module named statsmodels: >>> import statsmodels Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> import statsmodels ModuleNotFoundError: No module named 'statsmodels'...
🌐
Microsoft Fabric Community
community.fabric.microsoft.com › t5 › Desktop › Python-Error › td-p › 3396757
Solved: Python Error - Microsoft Fabric Community
August 27, 2023 - I'm new to using PowerBi and Python and have tried enrolling on a course that shows how to build up a stocks and shares dashboard. I've used the commenads suggested but Python is coming up with the following error Details: "ADO.NET: Python script error. ModuleNotFoundError: No module named 'yfi...
🌐
Streamlit
discuss.streamlit.io › community cloud
No module named 'numpy' during installing Riskfolio-Lib, after installing numpy - Community Cloud - Streamlit
February 25, 2023 - I consistently getting the following attempting to deploy my app to Streamlit cloud. Essentially the installation of Riskfolio-Lib cannot find the installed numpy. I have managed to get it working once but it still come…