I am trying to install and utilize pymer4 package functionalities in Databricks which requires rpy2 to be installed as well. Under Library in the Cluster I am able to install them, it even says "Installed", but when I try to import them then it gives error, as if it was not installed properly. In local system it works perfectly.
from pymer4.test_install import test_install
Error is:
ImportError: No module named 'pandas.core.dtypes'
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<command-2946392196605768> in <module>()
----> 1 from pymer4.test_install import test_install
/databricks/python/lib/python3.5/site-packages/pymer4/__init__.py in <module>()
6 "__version__"]
7
----> 8 from .models import Lmer, Lm
9 from .simulate import (easy_multivariate_normal,
10 simulate_lm,
/databricks/python/lib/python3.5/site-packages/pymer4/models.py in <module>()
2 import rpy2.robjects as robjects
3 from rpy2.robjects.packages import importr
----> 4 from rpy2.robjects import pandas2ri
5 import rpy2
6 from copy import copy
/databricks/python/lib/python3.5/site-packages/rpy2/robjects/pandas2ri.py in <module>()
14 from pandas.core.series import Series as PandasSeries
15 from pandas.core.index import Index as PandasIndex
---> 16 from pandas.core.dtypes.api import is_datetime64_any_dtype
17 import pandas
18 import numpy
ImportError: No module named 'pandas.core.dtypes'
Was able to solve my own problem. It was nothing but version issues of dependent packages of pymer4 package.
Changed the version of following packages with the latest one prior to release date of pymer4 and it worked:
matplotlib==3.0.2
pandas==0.23.4
rpy2==2.9.4
tzlocal
Related
I am trying to run this tutorial in colab.
However, when I try to import a bunch of modules:
import io
import torch
from torchtext.utils import download_from_url
from torchtext.data.utils import get_tokenizer
from torchtext.vocab import build_vocab_from_iterator
It gives me the errors for extract_archive and build_vocab_from_iterator:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-a24e72502dbc> in <module>()
1 import io
2 import torch
----> 3 from torchtext.utils import download_from_url, extract_archive
4 from torchtext.data.utils import get_tokenizer
5 from torchtext.vocab import build_vocab_from_iterator
ImportError: cannot import name 'extract_archive'
ImportError Traceback (most recent call last)
<ipython-input-4-02a401fd241b> in <module>()
3 from torchtext.utils import download_from_url
4 from torchtext.data.utils import get_tokenizer
----> 5 from torchtext.vocab import build_vocab_from_iterator
6
7 url = 'https://s3.amazonaws.com/research.metamind.io/wikitext/wikitext-2-v1.zip'
ImportError: cannot import name 'build_vocab_from_iterator'
Please help me with this one.
You need to upgrade torchtext first
!pip install -U torchtext==0.8.0
Currently, version 0.8.0 works with torch 1.7.0 (no need to upgrade torch, torchvision)
Update (sep 2021)
Currently, torchtext is already 0.10.0 and you don't need to upgrade anything.
Update December 2021
!pip install -U torchtext==0.10.0
torchtext.data becomes torchtext.legacy.data
use:
from torchtext.legacy.data import Field, TabularDataset, BucketIterator, Iterator
credit
You can use:
pip install -U torchtext==0.6.0
if 0.8 version is not available
This might help solve your problem:
conda install -c pytorch torchtext==0.8
I'm trying to import xgboost into jupyter-notebook but get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-9-a585b270d0df> in <module>
1 import pandas as pd
2 import numpy as np
----> 3 import xgboost
~/.local/lib/python3.6/site-packages/xgboost/__init__.py in <module>
14 from . import tracker # noqa
15 from .tracker import RabitTracker # noqa
---> 16 from . import dask
17 try:
18 from .sklearn import XGBModel, XGBClassifier, XGBRegressor, XGBRanker
~/.local/lib/python3.6/site-packages/xgboost/dask.py in <module>
31 from .training import train as worker_train
32 from .tracker import RabitTracker
---> 33 from .sklearn import XGBModel, XGBClassifierBase, xgboost_model_doc
34
35 # Current status is considered as initial support, many features are
ModuleNotFoundError: No module named 'xgboost.sklearn'
I've downloaded sklearn as well as sci-kit learn and they work fine...
Any idea what the problem is?
You might need to install your packages properly.
For best practice, you'll need to use a conda environment. Check out how it works here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
Once you have created your environment, activate it and then install all the packages you need. Presumably, you'll have to run the command:
conda install -c conda-forge xgboost
pip install -U scikit-learn
To install your machine learning packages.
XGBOOST is in xgboost module: It should be imported as:
`from xgboost import XGBRegressor`
I am getting the following error in Jupyter Note Book when running the code below in Python.
import talib
I get the following
ImportError Traceback (most recent call last)
<ipython-input-20-29b7d6c547d4> in <module>()
4 import numpy as np
5 import tensorflow
----> 6 import talib
7 import _talib
8 import alpaca_trade_api as tradeapi
ImportError: No module named 'talib'
I am running Anaconda on a MAC
I have looked at all of the existing questions on this and found nothing.
When I use the PIP freeze command I see the following library and version
TA-Lib==0.4.17
The folder talib exists in the following path
anaconda3/lib/python3.7/site-packages
I've pip installed folium and get this error when I try to import it in when Im working in my home directory:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-af6e4f19ef00> in <module>()
----> 1 import folium
//anaconda/lib/python2.7/site-packages/folium-0.3.0.dev0- py2.7.egg/folium/__init__.py in <module>()
3 from __future__ import absolute_import
4
----> 5 from folium.folium import Map, initialize_notebook, CircleMarker
6
7 from folium.map import (FeatureGroup, FitBounds, Icon, LayerControl, Marker,
//anaconda/lib/python2.7/site-packages/folium-0.3.0.dev0- py2.7.egg/folium/folium.py in <module>()
13 import json
14
---> 15 from branca.colormap import StepColormap
16 from branca.utilities import color_brewer
17 from branca.six import text_type, binary_type
ImportError: No module named branca.colormap
However, i can import it when I cd to /Library/Python/2.7/site-packages.... What gives?
Did you install the package with Anaconda? It looks like it's reading the package from Anaconda python's package install locations. A few things to try:
conda install branca
pip install branca
I am using scikit learn 0.15.0. When I try to import sklearn.mixture I get
ImportError: cannot import name choice
Any ideas?
===================================================================
In [1]: **from sklearn import mixture**
ImportError Traceback (most recent call last)
<ipython-input-1-05bc76cab98d> in <module>()
----> 1 from sklearn import mixture
/home/f/anaconda/lib/python2.7/site-packages/sklearn/mixture/__init__.py in <module>()
3 """
4
----> 5 from .gmm import sample_gaussian, log_multivariate_normal_density
6 from .gmm import GMM, distribute_covar_matrix_to_match_covariance_type
7 from .gmm import _validate_covars
/home/f/anaconda/lib/python2.7/site-packages/sklearn/mixture/gmm.py in <module>()
16 from ..utils import check_random_state, deprecated
17 from ..utils.extmath import logsumexp, pinvh
---> 18 from .. import cluster
19
20 from sklearn.externals.six.moves import zip
/home/f/anaconda/lib/python2.7/site-packages/sklearn/cluster/__init__.py in <module>()
4 """
5
----> 6 from .spectral import spectral_clustering, SpectralClustering
7 from .mean_shift_ import mean_shift, MeanShift, estimate_bandwidth, \
8 get_bin_seeds
/home/f/anaconda/lib/python2.7/site-packages/sklearn/cluster/spectral.py in <module>()
16 from ..neighbors import kneighbors_graph
17 from ..manifold import spectral_embedding
---> 18 from .k_means_ import k_means
19
20
/home/f/anaconda/lib/python2.7/site-packages/sklearn/cluster/k_means_.py in <module>()
28 from ..utils import as_float_array
29 from ..utils import gen_batches
---> 30 from ..utils.random import choice
31 from ..externals.joblib import Parallel
32 from ..externals.joblib import delayed
ImportError: cannot import name choice
from sklearn.mixture import GaussianMixture
using this would make it more specific to work with .gmm,
and
from sklearn.cluster import KMeans
for:
16 from ..neighbors import kneighbors_graph
17 from ..manifold import spectral_embedding
---> 18 from .k_means_ import k_means
As noted, it might have to do with old files (that are implemented in python as opposed to libraries?) in a new package you probably updated using pip install -U packagename (in my case pip install -U scikit-learn) It might be worth first trying to uninstall the package and install it again before manually deleting stuff... (worked in my case)
uninstall
(in my case run it on Anaconda Command prompt):
pip uninstall scikit-learn
then:
pip install -U numpy scipy scikit-learn
(added dependencies just in case)
then just to be sure
pip install scikit-learn
should say it's installed
I was getting the same error when I tried to import KMeans as : from sklearn.cluster import KMeans
Error > ImportError: cannot import name choice
I found the answer here: https://github.com/scikit-learn/scikit-learn/issues/3461
Since I have upgraded to Scikit version 0.15 a few days back, the older version of random.so was present in /usr/local/lib/python2.7/dist-packages/sklearn/utils.
I manually deleted it and now I do not get the error anymore.
Hope this helps.
New implementation is
from sklearn import mixture
model = mixture.GaussianMixture(n_components=3, covariance_type='full')
Just replace the first two lines