cannot import name '_imaging' from 'PIL' in manim Linux ( Ubuntu) - python

soutrik#soutrik-X541UJ:~/manim-folder/manim$ python3.7 -m manim example_scenes.py SquareToCircle -pl
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/soutrik/manim-folder/manim/manim.py", line 2, in <module>
import manimlib
File "/home/soutrik/manim-folder/manim/manimlib/__init__.py", line 4, in <module>
import manimlib.extract_scene
File "/home/soutrik/manim-folder/manim/manimlib/extract_scene.py", line 9, in <module>
from manimlib.scene.scene import Scene
File "/home/soutrik/manim-folder/manim/manimlib/scene/scene.py", line 11, in <module>
from manimlib.camera.camera import Camera
File "/home/soutrik/manim-folder/manim/manimlib/camera/camera.py", line 7, in <module>
from PIL import Image
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 69, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)
so i tried to open the camera.py and change the PIL to pillow and then it shows this
soutrik#soutrik-X541UJ:~/manim-folder/manim$ python3.7 -m manim example_scenes.py SquareToCircle -pl
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/soutrik/manim-folder/manim/manim.py", line 2, in <module>
import manimlib
File "/home/soutrik/manim-folder/manim/manimlib/__init__.py", line 4, in <module>
import manimlib.extract_scene
File "/home/soutrik/manim-folder/manim/manimlib/extract_scene.py", line 9, in <module>
from manimlib.scene.scene import Scene
File "/home/soutrik/manim-folder/manim/manimlib/scene/scene.py", line 11, in <module>
from manimlib.camera.camera import Camera
File "/home/soutrik/manim-folder/manim/manimlib/camera/camera.py", line 7, in <module>
from pillow import Image
ModuleNotFoundError: No module named 'pillow'
so no module huh? but if i do python3.7 -m pip install pillow I get
soutrik#soutrik-X541UJ:~/manim-folder/manim$ python3.7 -m pip install pillow
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (7.0.0)
I also tried Pillow
soutrik#soutrik-X541UJ:~/manim-folder/manim$ python3.7 -m pip install Pillow
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (7.0.0)
so how do i install it inside this manim folder ? or do i not need to do that ? do i need to add something to $PATH ? i am relatively new to Linux but even back in windows i didnt know much about PATH just added python3.7 to it to access from anywhere but in linux i can access python from anywhere without addidn to path ( did it automatically add to path ) so maybe its because pillow is not added to path since i cant use it from manims folder
also i tried to install PIL
soutrik#soutrik-X541UJ:~/manim-folder/manim$ python3.7 -m pip install PIL
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
---------------------EDIT-1--------------------------
when in home directory and i run
>>>from PIL import Image
I get
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 69, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)

I had the same problem, doing this resolved my issue
pip install -U Pillow

Related

ipykernel not working on mac m1 in local pipenv environment

I am trying to use Jupyter Notebooks on a Mac M1 within a local pipenv environment. Here is the commands I use:
(in directory)>pipenv shell
(in directory)>pipenv install pandas
(in directory)>pipenv install ipykernel
(in directory)>python -m ipykernel
Note that this does NOT happen during global python environment, where I don't use pipenv and python -m ipykernel works as intended along with Jupyter notebook.
This is the response I get from the last command given.
❯ python -m ipykernel
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/__main__.py", line 2, in <module>
from ipykernel import kernelapp as app
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 51, in <module>
from .ipkernel import IPythonKernel
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/ipkernel.py", line 17, in <module>
from .comm import CommManager
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/comm/__init__.py", line 1, in <module>
from .comm import * # noqa
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/comm/comm.py", line 12, in <module>
from ipykernel.kernelbase import Kernel
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/kernelbase.py", line 35, in <module>
import psutil
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/psutil/__init__.py", line 123, in <module>
from . import _psosx as _psplatform
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/psutil/_psosx.py", line 14, in <module>
from . import _psutil_osx as cext
ImportError: dlopen(/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/psutil/_psutil_osx.cpython-310-darwin.so, 0x0002): tried: '/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/psutil/_psutil_osx.cpython-310-darwin.so'
(mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))

ModuleNotFoundError: No module named 'spacy.lang.en.tag_map' when installing plasticityai / magnitude

Installed plasticityai/magnitude (https://github.com/plasticityai/magnitude#installation)
Getting the following error when trying to run:
ModuleNotFoundError: No module named 'spacy.lang.en.tag_map'
I have reinstalled spacy with newest version using pip3. Running python3.
Command I am trying to run:
python3 -m pymagnitude.converter -i /Users/rob/Desktop/videos/glove.6B/glove.6B.300d.txt -o /Users/rob/Desktop/vectors/
Full output:
Traceback (most recent call last):
File "/usr/local/Cellar/python#3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/local/Cellar/python#3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/usr/local/lib/python3.9/site-packages/pymagnitude/__init__.py", line 80, in <module>
from pymagnitude.third_party.allennlp.commands.elmo import ElmoEmbedder
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/commands/__init__.py", line 8, in <module>
from allennlp.commands.configure import Configure
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/commands/__init__.py", line 13, in <module>
from allennlp.commands.predict import Predict
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/commands/predict.py", line 54, in <module>
from allennlp.predictors.predictor import Predictor, JsonDict
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/predictors/__init__.py", line 13, in <module>
from allennlp.predictors.constituency_parser import ConstituencyParserPredictor
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/predictors/constituency_parser.py", line 7, in <module>
from spacy.lang.en.tag_map import TAG_MAP
ModuleNotFoundError: No module named 'spacy.lang.en.tag_map'' ```
Issue is version of Spacy installed via pip was incorrect. Uninstalled Spacy from global pip, and works fine.

Import Error when installing python3 kernel for Jupyter Notebook

My python3 kernel for jupyter notebook was not starting, so I uninstalled it. I then ran these commands to create a new python3 kernel.
python3 -m pip install ipykernel
python3 -m ipykernel install --user
However, I get an error when running python3 -m ipykernel install --user.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/ipykernel/connect.py", line 11, in <module>
from IPython.core.profiledir import ProfileDir
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/__init__.py", line 56, in <module>
from .terminal.embed import embed
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/terminal/embed.py", line 16, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/terminal/interactiveshell.py", line 19, in <module>
from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
from .application import Application
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/application/__init__.py", line 1, in <module>
from .application import Application
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/application/application.py", line 42, in <module>
from prompt_toolkit.buffer import Buffer
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/buffer.py", line 33, in <module>
from .auto_suggest import AutoSuggest, Suggestion
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/auto_suggest.py", line 19, in <module>
from .document import Document
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/document.py", line 8, in <module>
from typing import (
ImportError: cannot import name 'NoReturn'
This is the same error I was getting with the original python3 kernel before I removed it. How can I solve this issue?
I solved this issue by uninstalling and reinstalling Anaconda.
It seems, like it's problem with python version, Typing.NoReturn is new for python 3.6.2.
Try to install prompt-toolkit with a lower version, for instance 2.0.10. It worked for me:
python3 -m pip install prompt-toolkit==2.0.10
Then try again:
python3 -m ipykernel install --user

Windows, Python27 ImportError: cannot import name IncompleteRead

I have read many of the questions and answers regarding "IncompleteRead" most, if not all, of them end up with a recommendation to uninstall and reinstall pip, or upgrade pip, or uninstall and reinstall the package you are trying to install.
I am not able to even upgrade pip or uninstall it.
Here is the traceback:
c:\Python27>python.exe -m pip install -U pip
Traceback (most recent call last):
File "c:\Python27\lib\runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name)
File "c:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "c:\Python27\lib\site-packages\pip\__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "c:\Python27\lib\site-packages\pip\_internal\__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "c:\Python27\lib\site-packages\pip\_vendor\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "c:\Python27\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 11, in <module>
from .exceptions import (
File "c:\Python27\lib\site-packages\pip\_vendor\urllib3\exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
ImportError: cannot import name IncompleteRead
Any suggestions?
You can try and remove requests module first dist-packages
rm -rf python2.7/dist-packages/requests*
pip module need requests module to download packages from Python Package Index.
Hope this might help
I suggest you download the package yourself from here or find it yourself, and then try pip install urllib3-1.25.7-py2.py3-none-any.whl (replace the filename with the wheel you download). This way, you can reinstall urllib3 without importing it first.

Can't install python2 kernel for jupyter-notebook on MacOS

I'm trying to install the python2 kernel for jupyter notebook on my Macbook while following this page :
https://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-python-2-and-3
..but get the following error, which is rather cryptic for a (kind of) newb like me :
Alexandres-MBP ~ python2.7 -m ipykernel install
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/alex/Library/Python/2.7/lib/python/site-packages/ipykernel/__main__.py", line 2, in <module>
from ipykernel import kernelapp as app
File "/Users/alex/Library/Python/2.7/lib/python/site-packages/ipykernel/kernelapp.py", line 38, in <module>
from .iostream import IOPubThread
File "/Users/alex/Library/Python/2.7/lib/python/site-packages/ipykernel/iostream.py", line 25, in <module>
from jupyter_client.session import extract_header
File "/Users/alex/Library/Python/2.7/lib/python/site-packages/jupyter_client/session.py", line 51, in <module>
from dateutil.tz import tzutc
File "/Users/alex/Library/Python/2.7/lib/python/site-packages/dateutil/tz/__init__.py", line 2, in <module>
from .tz import *
File "/Users/alex/Library/Python/2.7/lib/python/site-packages/dateutil/tz/tz.py", line 19, in <module>
from six.moves import _thread
ImportError: cannot import name _thread
How do I solve that?
Oh and first post on Stack Overflow so I hope I'm asking in the right place.
Edit : forgot to mention I installed everything with brew.

Categories

Resources