I am trying to use the package ktrain's text function
text.TransformerSummarizer()
However, when I try to use it I get the error that
TransformerSummarizer() requires PyTorch to be installed.
I installed PyTorch using different variations of conda and pip, as well as the command given on the pytorch website. After it installs and I try to use it I get:
from ktrain import text
import torch
from transformers import BartForConditionalGeneration
ts = text.TransformerSummarizer()
ImportError: cannot import name 'BartForConditionalGeneration' from 'transformers' (C:\Users\user\AppData\Roaming\Python\Python37\site-packages\transformers\__init__.py)
Any suggestions of how to fix this? Thank you!
Hi so I'm trying to use the make_pipeline module in sklearn. But when I try to import it with:
from sklearn.pipeline import make_pipeline
I get this error:
ImportError: cannot import name '_print_elapsed_time'
I've googled it but there seems to be no other posts about this. I tried reinstalling scikitlearn but I still get the same error :/ Anyone have any ideas?
It looks like this was a bug introduced into one of the newer versions of scikit-learn (I got this same issue in version 0.21.2).
I was able to fix this by downgrading to scikit-learn version 0.20.0
>> pip install scikit-learn==0.20.0
When i try to import WordEmbeddingSimilarityIndex, it's giving me the following error:
>> from gensim.models import WordEmbeddingSimilarityIndex
ImportError: cannot import name 'WordEmbeddingSimilarityIndex
The same issue occurs for SparseTermSimilarityMatrix function:
>> from gensim.similarities import SparseTermSimilarityMatrix
ImportError: cannot import name 'SparseTermSimilarityMatrix
Note: I have installed and imported gensim, gensim.models and gensim.similarities. But still it's giving me the ImportError while importing the above mentioned functions.
Can you tell me what I am doing wrong, please?
Fix is change "models" to "similarities"
from gensim.similarities import WordEmbeddingSimilarityIndex
it works in gensim 4.0.1
Try to check the version of gensim that you are using. Usually, the older versions of gensim cause this issue.
from gensim.models import WordEmbeddingSimilarityIndex
print(gensim.__version__)
if the gensim version is 3.6.x or older update it to 3.7.x or latest version by running the below command. Once you update gensim version should get rid of this issue.
pip install --upgrade gensim
When I try:
>>> from skimage import io
I get at the end the following:
from ..color import rgb2gray
ImportError: cannot import name 'rgb2gray' from 'skimage.color' (C:\Users\user\A
ppData\Local\Programs\Python\Python37-32\lib\site-packages\skimage\color\__init_
_.py)
Although I have installed the packages: matplotlib, scipy, pillow, numpy and six
How can I fix it? Any help would be appreciated
In case you run into this error from inside a Jupyter Notebook, try restarting the kernel as suggested in this GitHub issue.
That solved the problem for me.
It looks like you haven't installed scikit-image package.
Try this on terminal:
pip install -U scikit-image
And then try importing like this:
from skimage import io
from skimage.color import rgb2gray
If you still got the error or you have installed the package previously,
try reinstalling the package first.
If it still don't resolve your issue, then try updating the following packages:
matplotlib, scipy, pil, numpy and six
However, try not to import all of the subpackages to improve loading time. You can however try something like:
from skimage import color
...
gray_img = color.rgb2gray(img)
If you still got errors, make sure that you are using the correct python kernel and dependent modules are updated and installed.
If that did not help either, then try Anaconda, it come with many pre-installed packages.
Leave a comment if you still have a problem :)
three ways to convert RGB2Gray:
opencv:
import cv2
img=cv2.imread("file.jpg",0) [enter link description here][1]
or you can do this:
img=cv2.imread("file.jpg")
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.COLOR_BGR2GRAY beacause it reads BGR mode.
another methods you can look this link:
enter link description here
It happened to me once when I import skimage using env conda on Jupyter. I installed by pip or conda in env, that error happened. However, after restart the Jupyter, it worked.
I am trying to import matplotlib.finance module in python so that I can make a Candlestick OCHL graph. My matplotlib.pyplot version is 2.00. I've tried to import it using the following commands:
import matplotlib.finance
from matplotlib.finance import candlestick_ohlc
I get this error:
warnings.warn(message, mplDeprecation, stacklevel=1)
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.
Then instead of using the above lines in python I tried using the following line:
import mpl_finance
I get this error:
ImportError: No module named 'mpl_finance'
What should I do to import candlestick from matplotlib.pyplot?
I've stopped using mpl_finance (and plotly) since they are too slow. Instead I've written an optimized finance plotting library, finplot, which I use to backtest up to 107 candles.
Here's a small example:
import yfinance as yf
import finplot as fplt
df = yf.download('SPY',start='2018-01-01', end = '2020-04-29')
fplt.candlestick_ochl(df[['Open','Close','High','Low']])
fplt.plot(df.Close.rolling(50).mean())
fplt.plot(df.Close.rolling(200).mean())
fplt.show()
Examples included show SMA, EMA, Bollinger bands, Accumulation/Distribution, Heikin Ashi, on balance volume, RSI, TD sequential, MACD, scatter plot indicators, heat maps, histograms, real-time updating charts and interactive measurements; all with sensible defaults ready for use.
I do dogfooding every day, drop me a note or a pull request if there is something you want. Hope you take it for a spin!
In 2020, one can now pip install mplfinance
What this warning tells you is that the finance module will be removed at some point.
At the moment you don't need to worry about this warning. It will only affect you when you update to a yet to be released version 2.2 of matplotlib, in which case you'll need to change your imports.
If you already want to be compatible with future versions now, you can download the mpl_finance module from
https://github.com/matplotlib/mpl_finance .
After having downloaded the files, you may install in the usual way,
python setup.py install
Alternatively you may try installing through pip,
pip install https://github.com/matplotlib/mpl_finance/archive/master.zip
The reason for this is that the people at matplotlib want to keep their code clean and not maintain a specialized sidepackage like this in the main code. They probably also do not want to maintain the package and spend resources on it, which can be better used in the core development.
Since mpl_finace is not on pip now, you may also want to use following command to install mpl_finance by pip:
pip install https://github.com/matplotlib/mpl_finance/archive/master.zip
mpl_finance is no longer part of matplotlib. Install the module directly from gitHub via pip
pip install https://github.com/matplotlib/mpl_finance/archive/master.zip
and import it with
from mpl_finance import candlestick_ohlc
Then it works the same as before.
There is a new version of matplotlib finance, with documentation, here:
https://pypi.org/project/mplfinance/
https://github.com/matplotlib/mplfinance
Install with: pip install --upgrade mplfinance
Or with: conda install -c conda-forge mplfinance
NOTE: The package name no longer has the dash or underscore:
It is now mplfinance (not mpl-finance, nor mpl_finance)
I'm working on google colab , i got the same problem . then what i did -for python3.6
import mpl_finance
from mpl_finance import candlestick_ohlc
Plotly.py, a web-browser based, interactive plotting module has finance plotting functions https://plot.ly/python/candlestick-charts/. And it is maintained.
Simply use pip install mpl_finance for Windows or pip3 install mpl_finance for Linux/Unix for installation.
Then use from mpl_finance import candlestick_ohlc to call the library in the Jupyter notebook!
Replace from matplotlib.finance import candlestick_ohlc with from mplfinance.original_flavor import candlestick_ohlc , That should work.