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.
Related
My issue is when trying to import the DCSBM model:
Code:
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import hyppo
from hyppo.time_series import _utils as _utils
from graspy.embed import AdjacencySpectralEmbed
from graspy.models import DCSBMEstimator
from graspy.models import EREstimator
from graspy.models import SBMEstimator
from graspy.models.sbm import _block_to_full, _get_block_indices
from graspy.simulations import er_np, sbm
Error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-33-287386449480> in <module>()
8 from hyppo.time_series import _utils as _utils
9 from graspy.embed import AdjacencySpectralEmbed
---> 10 from graspy.models import DCSBMEstimator
11 from graspy.models import EREstimator
12 from graspy.models import SBMEstimator
2 frames
/usr/local/lib/python3.7/dist-packages/graspy/inference/latent_distribution_test.py in <module>()
26 from sklearn.metrics.pairwise import PAIRWISE_KERNEL_FUNCTIONS
27 from hyppo.ksample import KSample
---> 28 from hyppo._utils import gaussian
29
30 _VALID_DISTANCES = list(PAIRED_DISTANCES.keys())
ModuleNotFoundError: No module named 'hyppo._utils'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
I think hyppo._utils doesn't exist and has been replaced by hyppo.time_series and inside that folder there exists the required _utils package.
How do we fix this?
I was just trying to run the tutorial: https://docs.neurodata.io/notebooks/pedigo/graspologic/2020/09/24/latent_model_tutorial.html
Run on Google colab
This line
from hyppo.time_series import _utils as _utils was added from me trying to fix the issue, but doesn't work.
Looks like you're using an old version of the package - it's called "graspologic" now. If you pip install graspologic, from graspologic.models import DCSBMEstimator should work fine. Just replace everything in that code that says "graspy" with "graspologic".
we're happy to answer questions on github issues as well! (I'm one of the people who contributes to the package)
My anaconda spyder pandas_datareader.data.DataReader() doesn't work after installing yfinance package. Actually yfinance asks me to install the multitasking package, and this seems to be the cause of the error, when a call DataReader().
File "/Users/Daniel/opt/anaconda3/lib/python3.8/site-packages/yfinance/multi.py", line 95, in download_time.sleep(0.01)
I could see some similar claims on the internet, but without a solution.
The simplified code is:
import pandas as pd
import pandas_datareader.data as web
import numpy as np
import yfinance as yf
yf.pdr_override()
import datetime
def dataQuery(pSeriesName, pSeriesSource, pInitDate):
df = web.DataReader(pSeriesName, pSeriesSource, pInitDate)
return df
initDate2 = returnLastYMD(initDate)
cpiMomSlice = dataQuery('CPIAUCSL', 'fred', initDate2).pct_change()
And spyder console error log:
My python file looks like this:
import sys, os
sys.path.append("../..")
sys.path.append("..")
sys.path.append(os.getcwd())
#import pdb
from sklearn.preprocessing import StandardScaler
from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
import copy
from tslib import tsUtils
from tslib.src.synthcontrol.syntheticControl import RobustSyntheticControl
from tslib.src.synthcontrol.multisyntheticControl import MultiRobustSyntheticControl
But i keep receiving this error:
Traceback (most recent call last):
File "testScriptMultiSynthControlSVDV1.1.py", line 34, in <module>
from tslib import tsUtils
ImportError: cannot import name 'tsUtils'
While the tsUtils file is clearly inside the src folder. Any idea as to why I'm getting "cannot import name" error would be extremely helpful.
dir(module) lists all members of a file/module. From the print result, it is obvious that you do not have a member called tsUtils.
Basically you are trying to import some member/attribute which is not defined in that module/file.
Ensure you are working with right version of files.
I would suggest that first uninstall tsUtils using pip uninstall command then install again using pip install and restart your system.
I am trying to import folium into a Jupyter notebook I'm working on and I cannot seem to solve the import issues with the Folium library. Has anyone else solved this problem?
After encountering an error installing folium, I used the solution provided in this thread to install the module:
Python 3.6 Module cannot be found: Folium
Short summary: clone from github, install using the commandline.
This worked, but instead I encountered the following error further down the line when trying to import folium into my notebook:
Input:
import pandas as pd
import geopandas as gpd
import numpy as np
from geopandas.tools import sjoin
import folium
from folium.plugins import MarkerCluster
from folium.element import IFrame
import shapely
from shapely.geometry import Point
import unicodedata
import pysal as ps
Output:
ModuleNotFoundError Traceback (most recent call
last)
<ipython-input-162-0ae99a5c599e> in <module>()
4 from geopandas.tools import sjoin
5 import folium
----> 6 from folium.plugins import MarkerCluster
7 from folium.element import IFrame
8 import shapely
ModuleNotFoundError: No module named 'folium.plugins'
I have no idea why this works, but I was having the same problem and finally solved it with
import folium.plugins as plugins
cluster = folium.FeatureGroup(name='cluster')
cluster.add_child(plugins.MarkerCluster(locations=coords, popups=popups)
I am trying to do Google's deep learning course on Udemy. For assignment one I need to verify that the following modules are working on my machine, but can't get matplotlib.pyplot working. The python code I must get to compile is the following:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import os
import sys
import tarfile
from IPython.display import display, Image
from scipy import ndimage
from sklearn.linear_model import LogisticRegression
from six.moves.urllib.request import urlretrieve
from six.moves import cPickle as pickle
# Config the matplotlib backend as plotting inline in IPython
%matplotlib inline
When I compile and run this like so:
python3.6 nn_assignment_1.py
I get the following error:
Traceback (most recent call last):
File "nn_assignment_1.py", line 9, in <module>
from IPython import display, Image
ImportError: cannot import name 'Image'
Any ideas how to get matplotlib working for python 3 here? I have been banging my head against the keyboard for hours trying to figure this out.