简体   繁体   中英

spacy ImportError: cannot import name Deque in Jupyter Notebook

I want to use spacy in a Python project on Juptyer Notebook but when i try to import the module I get the Error "ImportError: cannot import name Deque". I installed spacy in PyCharm in my virtual env via pip install -U spacy

I've seen another question on here that was similar ( ImportError cannot import name Deque with spacy ) but I can import spacy in PyCharm just fine so I assume it's a Jupyter Notebook specific problem.

I also checked the spacy version on PyCharm and JN and they're both the same, however it seems like my virtual env and JN don't use the same Python Version (3.8.1 in my venv on PyCharm and 3.6.0 on JN) [Python Versions in PyCharm and JN] [1]

May that be the problem or is something else causing it?

I also tried to uninstall and install again in PyCharm but it didn't change anything and also tried to pip install spacy in JN again but that also didn't solve it, JN told me I might have to restart the kernel but after restarting it still couldn't import spacy without that error. I've tried so much that after some time i just get the error ImportError: cannot import name errors but I assume it's still the same problme.

I'm very grateful for any suggestions and tips!

So for future references: I just 'solved' this problem by making a new environment with Python 3.6 since afaik Jupyter Notebook doesn't support Python versions highter than 3.6.x as of now yet, set up a new venv and now both PyCharm and JN use the same Python version (3.6.12) and I could successfully import spacy. So I'm assuming the different Python versions really were the problem. Maybe it's not even necessary to create a new venv and everything but I wanted to start clean again to not have further problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM