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 Report: mplfinance doesn't import in jupyter notebook #230

Closed
elizabethexpialadocious opened this issue Aug 1, 2020 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@elizabethexpialadocious
Copy link

elizabethexpialadocious commented Aug 1, 2020

Describe the bug
mplfinance doesn't import in jupyter notebook

To Reproduce
Steps to reproduce the behavior:

  1. at shell: jupyter notebook
  2. in browser in jupyter, launch a notebook that imports mplfinance
  3. run a line containing "import mplfinance as mpf"
  4. error results: ModuleNotFoundError: No module named 'mplfinance'
  5. note that "import mplfinance as mpf" works as expected in ipython

Expected behavior
nothing (no error should occur)

Screenshots
image

Desktop (please complete the following information):

  • OS: Raspbian GNU/Linux 10 (buster)
  • Browser Firefrox 68.10.0esr (32-bit)
  • Version Linux xxx 5.4.51-v8+ #1327 SMP PREEMPT Thu Jul 23 11:11:34 BST 2020 aarch64 GNU/Linux, Python 3.7.3 (virtualenv), jupyter notebook --version 6.1.0
    file /usr/bin/python3.7:
    /usr/bin/python3.7: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=f6973949a18fc12743cc4397016f28a9580a1417, stripped

Error persists when running 32-bit kernel.

@elizabethexpialadocious elizabethexpialadocious added the bug Something isn't working label Aug 1, 2020
@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Aug 2, 2020

In my experience, unless the module has been misspelled (which doesn't appear to be the case based on your screenshot above), ModuleNotFoundError usually indicates that the install location is not within the search path for importing modules.

Since this is working for you under ipython, so have a simple way to find where your system installed mplfinance:

In [1]: import mplfinance as mpf
In [2]: mpf.__file__

To find out where your system is searching for modules

import sys
print(sys.path)

If you run the above for both ipython and in your jupyter notebook, I am guessing that you will find that sys.path is different for your ipython installation than it is for your jupyter notebook (and that the notebook's search path does not include the install location). This could be for various reasons such as environment variables, where jupyter is installed, whether you are running virtual and/or conda environments, etc. You can read more about the module search path here: https://docs.python.org/3/tutorial/modules.html#the-module-search-path

Note that if you are using a virtual environment, or conda environment, you have to (1) activate the environment before installing mplfinance and (2) activate the environment before running jupyter notebook. It may also be necessary to have a separate install of jupyter notebook in the activated environment (however depending on other path related factors that may or may not be necessary).

Let me know if the above gives you enough information to resolve the issue. If not, please provide the output from the above commands and I will do what I can to help further. All the best. --Daniel

@elizabethexpialadocious
Copy link
Author

That did it! Thank you Daniel! A little investigating got me to jupyter/notebook#3311 which suggested my deleting ~/.local/share/jupyter/kernels/python3/kernel.json; I don't know how that got there.
image works great! thank you!

@DanielGoldfarb
Copy link
Collaborator

Elizabeth,
Glad to hear it. All the best!
--Daniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants