Hello.
I recently installed Torchtext 0.3.1 and tqdm 4.32.1 and tried to use FastText.
However, the following error occurred:
torchtext.vocab.FastText()
0%| | 0/1 [00:00, ?it/s]
Traceback (most recent call last):
File "", line 1, in
File "/home/ros-slam/.local/lib/python3.5/site-packages/torchtext/vocab.py", line 411, in __init__
super(FastText, self).__init__(name, url=url, **kwargs)
File "/home/ros-slam/.local/lib/python3.5/site-packages/torchtext/vocab.py", line 280, in __init__
self.cache(name, cache, url=url, max_vectors=max_vectors)
File "/home/ros-slam/.local/lib/python3.5/site-packages/torchtext/vocab.py", line 370, in cache
vectors[vectors_loaded] = torch.tensor([float(x) for x in entries])
File "/home/ros-slam/.local/lib/python3.5/site-packages/torchtext/vocab.py", line 370, in
vectors[vectors_loaded] = torch.tensor([float(x) for x in entries])
ValueError: could not convert string to float: b'version="1.0"'
To find the cause of ValueError, I checked the vocab.py
class FastText(Vectors):
url_base = 'https://s3-us-west-1.amazonaws.com/fasttext-vectors/wiki.{}.vec'
def __init__(self, language="en", **kwargs):
url = self.url_base.format(language)
name = os.path.basename(url)
super(FastText, self).__init__(name, url=url, **kwargs)
It is assumed that the cause of this error occurred while accessing that website 'url_base'.
So, how can we solve this error?
I've looked here for a case of a similar problem to mine, but unfortunately it doesn't appear to be an unusual case.
I've also tried the code in 0.2.3 versions, but the same thing is happening.
Thank you in advance for your reply.
@justice-suri could you share some code to reproduce the error?
@zhangguanheng66 This error occurs just type on terminal.
My environment is like this.
Ubuntu : 16.04
Kernel : 4.15.0
Python : 2.7.12
Torchtext : 0.3.1
tqdm : 4.32.1
When I import torchtext on terminal, some error occur like here.
'>>> import torchtext
/home/ros-slam/.local/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.3) or chardet (2.3.0) doesn't match a supported version!
RequestsDependencyWarning)
/home/ros-slam/.local/lib/python2.7/site-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
Do you think this is causing an error?
If you are unable to import torchtext, it definitely needs to check the installation. I would suggest to upgrade urllib3 and chardet first.
@zhangguanheng66 torchtext is imported with warning.
As you see above, my environment enable to import trochtext with warning but It print error when I use the comment like this.
torchtext.vocab.FastText()
Then, Is it right the problem about urllib3 and chardet?
I just upgraded urllib3 and chardet and warning was disappeared.
But error still occured.
I will take a look at the problem.
I just did a quick test with torchtext-0.4.0 and didn't have a problem to load torchtext.vocab.FastText(). If possible, please clone the master branch from GitHub and install it with command "python setup.py install". It's pretty straightforward.
@zhangguanheng66
I try to install torchtext 0.4.0 and it works well in git folder.
But it didn't work in other folder like /home/myname.
torchtext.vocab.FastText()
0%| | 0/1 [00:00, ?it/s]
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.linux-x86_64/egg/torchtext/vocab.py", line 450, in __init__
File "build/bdist.linux-x86_64/egg/torchtext/vocab.py", line 319, in __init__
File "build/bdist.linux-x86_64/egg/torchtext/vocab.py", line 409, in cache
ValueError: could not convert string to float: version="1.0"
So that reason, I cannot apply this program.
It works in /home/myname/git/text/ here.
You can use torchtest.__version__ to check the version of torchtext being used. Very likely, you use 0.4.0 in the git folder. Try "pip uninstall torchtext" outside the git folder and re-install it again.
@zhangguanheng66 Thanks your answer.
I execute FastText() and the output is below.
>>> import torchtext
>>> torchtext.__version__
'0.4.0'
>>> torchtext.vocab.FastText()
0%| | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/torchtext/vocab.py", line 450, in __init__
File "build/bdist.linux-x86_64/egg/torchtext/vocab.py", line 319, in __init__
File "build/bdist.linux-x86_64/egg/torchtext/vocab.py", line 409, in cache
ValueError: could not convert string to float: version="1.0"
>>>
I deleted the older version and install 0.4.0. But the result is failed.
Is there any other way?
I'm so sorry that your help hasn't been resolved.
Could you create a completely fresh virtual environment (conda or virtualenv) and try reproducing the bug there, just to make sure that there was no lingering library errors?
Feel free to re-open the issue if you still have questions.