Forums

installing spacy

I'm on a free account, trying to install spacy in my virtual environment

(myenv) ... $pip install spacy

I get the following error. Has anyone else successfully installed spacy?

Collecting cytoolz<0.9,>=0.8 (from thinc<6.11.0,>=6.10.1->spacy) Exception: Traceback (most recent call last): File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/commands/install.py", line 335, in run wb.build(autobuilding=True) File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/download.py", line 809, in unpack_url unpack_file_url(link, location, download_dir, hashes=hashes) File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/download.py", line 715, in unpack_file_url unpack_file(from_path, location, content_type, link) File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/utils/init.py", line 599, in unpack_file flatten=not filename.endswith('.whl') File "/home/kjmazidi/.virtualenvs/myvenv/lib/python3.6/site-packages/pip/utils/init.py", line 484, in unzip_file zip = zipfile.ZipFile(zipfp, allowZip64=True) File "/usr/lib/python3.6/zipfile.py", line 1100, in init self._RealGetContents() File "/usr/lib/python3.6/zipfile.py", line 1167, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file

See here for how to install python modules on PythonAnywhere.

Those are exactly the instructions I followed.

hmm- i just randomly testing installing on python3.5 and python3.6 virtualenvs and those worked.

I can think of two problems: your free account may not have enough storage capacity (ie. it took ~300MB+ space to install, so it's possible that file was cut off while downloading because you exceeded maximum space capacity), or maybe (this is less likely) the cytoolz install tries to access something outside of pypi and is being blocked (free users can only access a whitelist, vs paying users get unlimited external internet access)

Interestingly, following the instructions above either within a virtual environment or not, it gets stuck at the same point: the 'File is not a zip file'.

The console tells me I have enough storage, about 400MB.

I think my best option is to upgrade my account and see if that helps.

Thanks for your suggestions. Fingers crossed.

This is disappointing. I upgraded my account, closed my bash consoles. Opened a new one and had the same problem. Here is the full trace:

17:44 ~ $ mkvirtualenv myenv --python=python3.6 Running virtualenv with interpreter /usr/bin/python3.6 Using base prefix '/usr' New python executable in /home/kjmazidi/.virtualenvs/myenv/bin/python3.6 Also creating executable in /home/kjmazidi/.virtualenvs/myenv/bin/python Installing setuptools, pip, wheel...done. virtualenvwrapper.user_scripts creating /home/kjmazidi/.virtualenvs/myenv/bin/predeactivate virtualenvwrapper.user_scripts creating /home/kjmazidi/.virtualenvs/myenv/bin/postdeactivate virtualenvwrapper.user_scripts creating /home/kjmazidi/.virtualenvs/myenv/bin/preactivate virtualenvwrapper.user_scripts creating /home/kjmazidi/.virtualenvs/myenv/bin/postactivate virtualenvwrapper.user_scripts creating /home/kjmazidi/.virtualenvs/myenv/bin/get_env_details (myenv) 17:45 ~ $ pip install spacy Collecting spacy Using cached spacy-2.0.5.tar.gz Collecting numpy>=1.7 (from spacy) Using cached numpy-1.13.3-cp36-cp36m-manylinux1_x86_64.whl Collecting murmurhash<0.29,>=0.28 (from spacy) Collecting cymem<1.32,>=1.30 (from spacy) Collecting preshed<2.0.0,>=1.0.0 (from spacy) Collecting thinc<6.11.0,>=6.10.1 (from spacy) Using cached thinc-6.10.2.tar.gz Collecting plac<1.0.0,>=0.9.6 (from spacy) Using cached plac-0.9.6-py2.py3-none-any.whl Collecting six (from spacy) Using cached six-1.11.0-py2.py3-none-any.whl Collecting pathlib (from spacy) Collecting ujson>=1.35 (from spacy) Collecting dill<0.3,>=0.2 (from spacy) Collecting requests<3.0.0,>=2.13.0 (from spacy) Using cached requests-2.18.4-py2.py3-none-any.whl Collecting regex==2017.4.5 (from spacy) Collecting ftfy<5.0.0,>=4.4.2 (from spacy) Collecting msgpack-python (from spacy) Collecting msgpack-numpy==0.4.1 (from spacy) Using cached msgpack_numpy-0.4.1-py2.py3-none-any.whl Collecting wrapt (from thinc<6.11.0,>=6.10.1->spacy) Collecting tqdm<5.0.0,>=4.10.0 (from thinc<6.11.0,>=6.10.1->spacy) Using cached tqdm-4.19.5-py2.py3-none-any.whl Collecting cytoolz<0.9,>=0.8 (from thinc<6.11.0,>=6.10.1->spacy) Exception: Traceback (most recent call last): File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/commands/install.py", line 335, in run wb.build(autobuilding=True) File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/download.py", line 809, in unpack_url unpack_file_url(link, location, download_dir, hashes=hashes) File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/download.py", line 715, in unpack_file_url unpack_file(from_path, location, content_type, link) File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/utils/init.py", line 599, in unpack_file flatten=not filename.endswith('.whl') File "/home/kjmazidi/.virtualenvs/myenv/lib/python3.6/site-packages/pip/utils/init.py", line 484, in unzip_file zip = zipfile.ZipFile(zipfp, allowZip64=True) File "/usr/lib/python3.6/zipfile.py", line 1100, in init self._RealGetContents() File "/usr/lib/python3.6/zipfile.py", line 1167, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file (myenv) 17:46 ~ $

So i next tried to install from source according to directions here: https://pypi.python.org/pypi/spacy

same error at the same spot

by the way, nltk installed with no problem, but I need spacy for my project

that is certainly quite weird- what happens if you just try to pip install cytoolz?

My spacy install into a 3.6 virtualenv installs fine, and I get a version 0.8.2 cytoolz

I tried

pip install cytoolz

and received 0.9.0

Then I tried pip install spacy again: this error below. Notice it says <0.9.

collecting cytoolz<0.9,>=0.8 (from thinc<6.11.0,>=6.10.1->spacy) Exception: Traceback (most recent call last): File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/commands/install.py", line 335, in run wb.build(autobuilding=True) File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/download.py", line 809, in unpack_url unpack_file_url(link, location, download_dir, hashes=hashes) File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/download.py", line 715, in unpack_file_url unpack_file(from_path, location, content_type, link) File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/utils/init.py", line 599, in unpack_file flatten=not filename.endswith('.whl') File "/home/kjmazidi/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/pip/utils/init.py", line 484, in unzip_file zip = zipfile.ZipFile(zipfp, allowZip64=True) File "/usr/lib/python3.6/zipfile.py", line 1100, in init self._RealGetContents() File "/usr/lib/python3.6/zipfile.py", line 1167, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file

So I uninstalled cytoolz and tried to install earlier version of cytoolz like this:

pip install cytoolz==0.8.2

and got the familiar not a zip file exception traceback

Is my syntax correct for installing cytoolz with a specific version?

so pip caches prior downloads. i wonder if it keeps trying to use the old truncated/incorrect file. You can try to rm -rf ~/.cache/pip or just a pip install --no-cache-dir

Thanks conrad. That was working until I ran out of room and then shot myself in the foot.

In order to get more room, I went a little crazy deleting everything and now bash won't recognize mkvirtualenv command.

Is there any way to wipe out my account and start fresh?

Deleting your account is definitely an option, but it might be worth just trying to get yours working again. Try this in a Bash console:

echo 'source virtualenvwrapper.sh' >> ~/.bashrc

then close the bash console and re-open a new one. mkvirtualenv should work again...

Yes! That worked! Finally I was able to install spacy and the necessary English model.

I am so impressed with PythonAnywhere's support staff. Without you guys I would have given up and tried another platform.

Glad we could help! :-D