My VS Code Editor for Python is not able to import transformers even though I have done a conda install and giving me the following error
Traceback (most recent call last):
File "c:/Users/I323017/Documents/Studies/question_answering_kinnal/src/main.py", line 3, in <module>
import transformers
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\__init__.py", line 107, in <module>
from .pipelines import (
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\pipelines.py", line 40, in <module>
from .tokenization_auto import AutoTokenizer
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_auto.py", line 49, in <module>
from .tokenization_flaubert import FlaubertTokenizer
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_flaubert.py", line 23, in <module>
from .tokenization_xlm import XLMTokenizer
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\transformers\tokenization_xlm.py", line 26, in <module>
import sacremoses as sm
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\__init__.py", line 2, in <module>
from sacremoses.tokenize import *
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\tokenize.py", line 10, in <module>
from sacremoses.util import is_cjk
File "C:\Users\I323017\AppData\Local\Continuum\anaconda3\lib\site-packages\sacremoses\util.py", line 11, in <module>
from joblib import Parallel, delayed
ModuleNotFoundError: No module named 'joblib'
May I know the problem here?
The error clearly suggests:
ModuleNotFoundError: No module named 'joblib'
Try pip install joblib
Also make sure you have latest torch and transformers library installed.
This seems to be an installation issue. If you have already installed transformers using conda install -c conda-forge transformers, an additional upgradation from the source using the below resolved my issue.
git clone https://github.com/huggingface/transformers.git
cd transformers
pip install .
As #Vishnukk has stated, this seems like an installation problem.
HuggingFace has now published transformers officially via their own conda channel
Doing conda install transformers -c huggingface should then work after removing the old version of transformers.
Related
I get the following error when trying to import simpletransformers:
Traceback (most recent call last):
File "...py", line 106, in <module>
from simpletransformers.classification import ClassificationModel, ClassificationArgs
File "/home/work/anaconda/lib/python3.6/site-packages/simpletransformers/classification/__init__.py", line 1, in <module>
from simpletransformers.classification.classification_model import ClassificationModel
File "/home/work/anaconda/lib/python3.6/site-packages/simpletransformers/classification/classification_model.py", line 32, in <module>
from tensorboardX import SummaryWriter
File "/home/work/anaconda/lib/python3.6/site-packages/tensorboardX/__init__.py", line 4, in <module>
from .record_writer import RecordWriter
File "/home/work/anaconda/lib/python3.6/site-packages/tensorboardX/record_writer.py", line 18, in <module>
from google.cloud import storage
File "/home/work/anaconda/lib/python3.6/site-packages/google/cloud/storage/__init__.py", line 38, in <module>
from google.cloud.storage.batch import Batch
File "/home/work/anaconda/lib/python3.6/site-packages/google/cloud/storage/batch.py", line 29, in <module>
from google.cloud import _helpers
File "/home/work/anaconda/lib/python3.6/site-packages/google/cloud/_helpers.py", line 33, in <module>
from google.protobuf import duration_pb2
File "/home/work/anaconda/lib/python3.6/site-packages/google/protobuf/duration_pb2.py", line 21, in <module>
create_key=_descriptor._internal_create_key,
AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
I already tried upgrading protobuf and have same protoc version like in this question:
How to solve "AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"?
I also tried upgrading other packages. What else could be the problem?
I am having the issue on cloud linux machine. On my local windows machine, there is no problem.
The protoc version I got through pip show protobuf and protoc --version were different. The version in pip was a bit outdated.
After I upgraded the pip version with
pip install --upgrade protobuf
the problem was solved.
If python3, use pip3 install --upgrade protobuf
I encountered the same issue of protobuf version is equal to protoc and error still exist. But after rebooting my computer, It's work.
I am going mad for installing and import tensorflow for 6 weeks. I did everything; I installed it from spyder, Conda prompt and with different commands like pip install tensorflow and conda install tensorflow. my python version is 3.7 and after install when I want to import tensorflow in spyder I get this message:
import tensorflow
Traceback (most recent call last):
File "<ipython-input-4-d6579f534729>", line 1, in <module>
import tensorflow
File "C:\Users\sally\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 27, in <module>
from tensorflow._api.v2 import audio
File "C:\Users\sally\Anaconda3\lib\site-packages\tensorflow\_api\v2\audio\__init__.py", line 8, in <module>
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "C:\Users\sally\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\sally\Anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 9, in <module>
from google.protobuf import symbol_database as _symbol_database
File "C:\Users\sally\Anaconda3\lib\site-packages\google\protobuf\symbol_database.py", line 184, in <module>
_DEFAULT = SymbolDatabase(pool=descriptor_pool.Default())
AttributeError: module 'google.protobuf.descriptor_pool' has no attribute 'Default
This is a very common issue. I have been there.
First: provide the following information:
- what operating system?
- do you want to run on cpu or gpu?
- if gpu, what gpu do you have?
- are your drivers up to date?
- Are your trying to run tensorflow though an IDE like Pycharm, is it more like Jupyter notebook stuff, or just cmd.
Second: There are some link that might be usefull. Here they are.
https://www.tensorflow.org/install/pip
https://www.tensorflow.org/install/gpu#software_requirements
There is a video that helped me, it might help you as well. With tensorflow it is really important to follow the instructions precisely, not missing any steps, and very important, not assuming that installing something with a higher version is no issue. If it says install 'whatever program'.version.1.1.x you can not install 'whatever program'.version.1.1.y
https://www.youtube.com/watch?v=qrkEYf-YDyI&t=1575s
I've installed Pytorch and Torchvision in the way suggested on their website via pip within a virtual environment (env), and whilst no errors occur during installation when I go to import torchvision in my python code the following error occurs.
Traceback (most recent call last):
File "demo.py", line 2, in <module>
import torchvision
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/__init__.py", line 2, in <module>
from torchvision import datasets
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/datasets/__init__.py", line 9, in <module>
from .fakedata import FakeData
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/datasets/fakedata.py", line 3, in <module>
from .. import transforms
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/transforms/__init__.py", line 1, in <module>
from .transforms import *
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 17, in <module>
from . import functional as F
File "/Users/QuinceyBee/env/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 5, in <module>
from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (/Users/QuinceyBee/env/lib/python3.7/site-packages/PIL/__init__.py)
I have tried creating new virtual environments to rebuild from scratch, tried to install via conda within a conda environment, however, neither of these resolved this issue.
I apologise for any format issues, this is the first time posting on here and also I'm relatively new to using python.
Any assistance would be greatly appreciated.
Pillow 7.0.0 removed PILLOW_VERSION, you should use version in your own code instead.
https://pillow.readthedocs.io/en/stable/deprecations.html#pillow-version-constant
If using Torchvision, there is a release planned this week (week 2, 2020) to fix it:
https://github.com/pytorch/vision/issues/1712#issuecomment-570286349
The options are:
wait for the new torchvision release
use the master version of torchvision as given below
pip install -U git+https://github.com/pytorch/vision)
install torchvision from a nightly, which also requires a pytorch from a nightly version
or install Pillow<7
pip install "pillow<7"
I am trying the code from sklearn.datasets import load_iris. For this I have installed sklearn module in my python 2.7.6 but it is showing me long error
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from sklearn.datasets import load_iris
File "C:\Python27\lib\site-packages\sklearn\datasets\__init__.py", line 23, in <module>
from .twenty_newsgroups import fetch_20newsgroups
File "C:\Python27\lib\site-packages\sklearn\datasets\twenty_newsgroups.py", line 53, in <module>
from ..feature_extraction.text import CountVectorizer
File "C:\Python27\lib\site-packages\sklearn\feature_extraction\__init__.py", line 10, in <module>
from . import text
File "C:\Python27\lib\site-packages\sklearn\feature_extraction\text.py", line 24, in <module>
from ..preprocessing import normalize
File "C:\Python27\lib\site-packages\sklearn\preprocessing\__init__.py", line 6, in <module>
from ._function_transformer import FunctionTransformer
File "C:\Python27\lib\site-packages\sklearn\preprocessing\_function_transformer.py", line 2, in <module>
from ..utils import check_array
ImportError: cannot import name check_array
I want to know if installing sklearn module is enough or am I missing something? Please Help. Also I am working on Win 8.1
Why are you using sklearn 0.13.1 when the latest version is 0.18? You are very out of date and probably have dependency issues.
If you want an easier life then install anaconda. All the package versions work together with no need to compile anything.
Installing sklearn is enough for reading the data.Probably the file is not retrieved by your version of sklearn.
Try to read the file from your drive
c:/Users/../site-packages/sklearn/datasets/data
directly and this can confirm the issue.
Typically the error
from ..utils import check_array
ImportError: cannot import name check_array
appears when there is a dependency version mismatch is there. To resolve the issue either
a) update to the latest version of sklearn via pip or easy_install . Or manually install
b) Create a Python virtual environment and try this. It will help you to manage the version specific depend libraries.
My two cents : Go for Anaconda or Enthought Python distributions if latest version of sklearn is okay. Else better to use virtualenv package in python to isolate the environments and avoid conflicts.
Happy Hacking
I have just installed Anaconda in a Ubuntu 14.04. Then I installed tensorflow using
conda install -c https://conda.anaconda.org/jjhelmus tensorflow
Then I installed protobuf
conda install -c https://conda.anaconda.org/anaconda protobuf
However, I am not able to solve this issue:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/daniel/anaconda2/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "/home/daniel/anaconda2/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
builtins.execfile(filename, *where)
File "/home/daniel/Documents/Cursos/UnB/Metodos Computacionais/2016/Notas de Aula/Part II - Aula 1 Regression Linear Models/biasVersusVarianceSeveralData.py", line 8, in <module>
import tensorflow as tf
File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 69, in <module>
from tensorflow.python.training import training as train
File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/training.py", line 149, in <module>
from tensorflow.python.training.saver import generate_checkpoint_state_proto
File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 29, in <module>
from google.protobuf.any_pb2 import Any
ImportError: No module named any_pb2
Use the instructions on the TensorFlow site.
TLDR;
I am posting this as an answer because people don't look for answers in the comments.
Here's my comment on the issue from github, hope this helps.
"For anyone else who is running into the same issue, I was also having similar problems when trying to import tensorflow on notebook via jupyter. The modules were installed using conda. After spending two days on it without any success (kept getting the same, no module any_pb2/contrib), it was obvious it was a notebook problem and not tensorflow related since I could import tensorflow from python shell. So I decided to switch back to vanilla python and installed everything manually (tensorflow via pip & got rid of jupyter & installed ipython instead) and now I am able to import tensorflow from my ipython notebook."
Original comment link: https://github.com/tensorflow/tensorflow/issues/1161#issuecomment-188664103
The following worked for me:
conda install -c https://conda.anaconda.org/jjhelmus tensorflow