ImportError: cannot import name 'HfApi' - huggingface-transformers

first time using hugging face transformers library and it's not getting through the import statement.
Running on Conda virtual environment Python 3.6
I also tried this below with the huggingface_hub library, and the error message is the same.
from huggingface_hub import HfApi
hf_api = HfApi()
models = hf_api.list_models()

I also faced a similar issue on my Python 3.6 environment. Installing hugging face on an environment with greater Python version was solved the issue.

Related

Rdkit - ImportError: DLL load failed

I have used pip install rdkit-pypi to install rdkit library. But when I type import rdkit as rd, it shows the error
ImportError: DLL load failed while importing rdBase: The specified module was not found.
I am using Anaconda as a base. What should I do to work with rdkit library?
I previously encountered this problem. After some reading, I came to know that the python version above 3.8.0 would not be compatible with rdkit. Even you need to change your base to rdkit.
I solve this by first downgrading the anaconda version with the python version lower than 3.8.0.
then I set my rdkit environment.
In this image u can see my python version and I'm not getting any error
In second image u can see my base to my-rdkit-envs

Importing gensim

I've installed gensim, however I keep getting an error when I try to import it
from gensim.models import Word2Vec
ImportError: cannot import name 'open'
I'm using the updated version of gensim 3.8.0 and smart_open 2.1.0.
I have reinstalled several times but still can't get it to work.
I also have the same problem, after that I found a solution:
pip install --upgrade gensim
You can install first , then you can import:
import gensim.downloader as gensim_api
import gensim
Works for Mac.

How to use Normal constructor correctly in pymc3?

When I use pymc3 to construct a normal distribution, I got error message. How to solve this problem?
I installed PyMC3 with windows Anaconda (version Anaconda3-2019.03-Windows-x86_64.exe). And running codes from official pymc3 tutorial "Getting started with PyMC3".
I tried to build a normal distribution with Normal constructor pm.Normal(). The codes are listed below
import numpy as np
import pymc3 as pm
basic_model = pm.Model()
with basic_model:
# Priors for unknown model parameters
alpha = pm.Normal('alpha', mu=0, sigma=10)
But got error message as the following:
AttributeError: module 'numpy.core.multiarray' has no attribute '_get_ndarray_c_version'
The problem is solved by removing theano 1.0.3 from Anaconda and performing pip install the latest version >=1.0.4.

import tensorflow SyntaxError: invalid syntax

Using Virtualenv on Mac I have encountered the showing SyntaxError when I
import tensorflow
I tried many times uninstall but now working... please help me!
Tensorflow is not supported on Python 3.7. You'll need to use python3.6 or earlier.
async which was fine as a variable name in earlier versions of Python, is a keyword in Python 3.7. This is why it is failing to import.

How to import packages/modules into spyder?

I just installed python in my MacOS using the Anaconda distribution. My problem is although the packages (eg. matplotlib, numpy, scipy) came included with the installation, I have to import them to spyder every time which is tedious and it's also tiring that that I have to remind spyder of their functionalities.
For eg, in Windows, I only needed to type in the console:
x=array([...,...,...])
but in my mac it would have to be:
import numpy as py
and then type into the console:
x=py.array([...,...,...])
I do notice that in that the spyder-python console (Windows version), there is a text saying,
Imported NumPy 1.8.1, SciPy 0.13.3, Matplotlib 1.3.1 + guidata 1.6.1, guiqwt 2.3.2
Type "scientific" for more details.
That is probably the reason why I don't have to import anything in Windows because Spyder already did it.
How do I do the same for Mac?
Thank you

Resources