How to fix mpl_finance package for MatPlotLib? - python

Getting this error message:
MatplotlibDeprecationWarning: The finance module has been deprecated in mpl 2.0 and will be removed in mpl 2.2. Please use the module mpl_finance instead.
How do I put in place the mpl_finance package instead. I have it installed in pip, but what is the proper import phraseology?
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
from matplotlib.finance import candlestick_ohlc
import matplotlib.dates as mdates
import pandas as pd
import pandas_datareader.data as web
from googlefinance import getQuotes
import json
from datetime import datetime
from forex_python.converter import CurrencyRates
from yahoo_finance import Share

All code for matplotlib.finance moved to a separate repository. Here is an example of usage. To answer your question:
from mpl_finance import candlestick_ohlc

To import a module which is installed through pip with the name x you would mostly want to do import x.
So, here
import mpl_finance
or to get one of its functions, e.g.
from mpl_finance import candlestick_ohlc

new version can be found here: https://pypi.org/project/mplfinance/

Related

Importing library in python (Pycharm)

These are the libraries within the script asked for import
## Import libraries
import numpy
import dill
import pandas
import peakutils
import os
import scipy
from scipy.signal import butter, lfilter, freqz
import smooth
from peakutils.plot import plot
from matplotlib import pyplot
I did several however, not for butter,lfilter, freqz, os,
what I have to do?
I imported several libraries but not all.

Streamlit Share cloud can not find package / module

I have transfered a locally running Streamlit file to the Streamlite-Share cloud. This Share-cloud envirnoment tells me, that the Python packeage pandas_datareader can not be found. Any idea what is to do now ? Thank you!
import streamlit as st
import datetime
import numpy as np
import pandas as pd
from pandas_datareader import data as pdr
from matplotlib import pyplot as plt
import matplotlib.dates as mdates
Traceback (most recent call last):
File "/app/streamlit_finance_data/str04.py", line 5, in <module>
from pandas_datareader import data as pdr
ModuleNotFoundError: No module named 'pandas_datareader'
When using Streamlit cloud you need to specify in your project the dependencies.
This can be done using an added reuirements.txt and specifying in it the libraries you want streamlit to install when it deploys your app.
This is elaborated in the documentation.

Unable to import PyroModule

I am trying to import PyroModule using: from pyro.nn import PyroModule but, I am getting this error:
ImportError: cannot import name 'PyroModule' from 'pyro.nn' (/home/karima/anaconda3/envs/my_env/lib/python3.7/site-packages/pyro/nn/init.py)
Here is the whole piece of code:
import os
from functools import partial
import torch
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import pyro
import pyro.distributions as dist
from torch import nn
import seaborn as sns
from pyro.nn import PyroModule
I think the issue is due to wrong installation of pyro module,
instead of this
pip install pyronn
can you try this
pip install pyro-ppl
Let me know how this goes
I was facing the same problem with my MAC. None of the suggestions worked for me. I resolved it by running python -m pip install pyro-ppl
I hope this helps.

Python in vscode: Import errors do not show up in terminal

I'm writing python scripts in vscode and recently I've been having a problem related to imports.
Lines of code above imports work and their output is displayed in the terminal:
print("hellow")
import matplotlib.pyplot as plt
import numpy as np
#from scipy.special import erfc
from scipy.linalg import solve
> hellow
Lines of code below the imports are not executed, but no errors are displayed in the terminal!
import matplotlib.pyplot as plt
import numpy as np
#from scipy.special import erfc
from scipy.linalg import solve
print("hellow")
>
I'm guessing there is something wrong with my vscode settings, but why are no errors showing up in the terminal?
Thanks for your help.

Cannot import Imread from Pylab

import numpy as np
import pandas as pd
import cv2
from matplotlib import pyplot as plt
from pylab import imread
from skimage.color import rgb2gray
from PIL import Image
from skimage import feature
I reinstalled Windows 10, so I had to reinstall Anaconda and Jupyter also.
I usually use these import statements, however, now I'm getting an error:
ImportError: cannot import name 'imread' from 'pylab'
(C:\Users\DELL\Anaconda3\lib\site-packages\pylab__init__.py)
Do you have any suggestions? I have installed Pylab, PIL and Matplotlib already.
Try to add:
from matplotlib.pyplot import imread
in stead of:
from pylab import imread

Categories

Resources