Pillow broke - hash collision: : 22 for both 1 and 1 - python

My Pillow installation is broken system-wide.
Either using my OS X pillow version, or other 'isolated' installations within anaconda environments, I always get the same error, while trying to process images:
AccessInit: hash collision: 22 for both 1 and 1
It used to work in the envs, but after some urllib installs it broke in the environments also.
I have tried, at the top of my script (to no avail):
import PIL.Image
sys.modules['Image'] = PIL.Image
from PIL import Image
I have already uninstalled an reinstalled Pillow, again to no avail.
my Python:
Python 2.7.14 |Anaconda, Inc.| (default, Oct 5 2017, 02:28:52)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
How can I make it work again?

Your problem is likely that two different Python modules are being imported with the same name - https://web.archive.org/web/20110121072135/https://jaredforsyth.com/blog/2010/apr/28/accessinit-hash-collision-3-both-1-and-1/
Without having access to your installation, it is hard to figure out exactly what is happening, so I would suggest tracking each import. A good start would be to see what is imported.
import sys
sys.modules
That, combined with going into the site-packages directory of your Python install and manually removing packages until you find the problematic package, will hopefully give you a good start.

Related

altair python package gives "Illegal instruction" on Raspberry PI

In my RaspberryPI ZERO W I got strange error when trying to import altair module in python script.
pi#raspberrypi:~ $ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import altair
Illegal instruction
pi#raspberrypi:~ $ pip3 freeze
altair==4.2.0
Does anybody have an idea if there is a version, which works on RaspberryPi? Or any other idea why it is happening?
Illegal Instruction means that you are importing a C extension that is compiled incorrectly for the system you are using. Altair itself doesn't have any C extensions, but it depends on a number of libraries that do include C extensions, which you can see in its requirements.txt file:
entrypoints
jinja2
jsonschema>=3.0
numpy
pandas>=0.18
toolz
I would suggest trying to import each of these libraries to narrow-down which package is incorrectly installed, and then search for information on how to correctly install the problematic package on RaspberryPi ZERO.

package installed but not showing in the pycharm's available packages

I installed the PyAutoGUI package using pip install pyautogui.
I can tell it's installed since I can import it using the PyCharm terminal:
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyautogui
>>> print(pyautogui)
<module 'pyautogui' from 'C:\\python\\anaconda3\\lib\\site packages\\pyautogui\\__init__.py'>
>>>
My problem is: When I try to add it to my project virtual environment, I can't find it on the available packages. Is there any way to add it manualy ?
P.S.: This is how I'm trying to add it:
File>Settings>Project>Project interpreter>install(the green plus button)>available packages>install
Since you cannot find PyAutoGUI on available packages (for me it is there), you can try running
pip install pyautogui
in the pycharm terminal. If you have already installed it in the global site-packages, pip will use the cached files in installation instead of downloading it again.
I work around this problem by uninstalling anaconda python and pycharm then reintalling pycharm and python (not anaconda), now i can add modules to my venvs no problem.
Note: at first, the available packages list was empty until i added "https://pypi.python.org/" to my repositories using the manage repositories button.

Importing python module in R

I am trying to import a python module in R using the reticulate package. The module can be found here. I cloned the repository and ran python setup.py install which ran successfully. If I open a python shell, I'm able to import debot. However, when I try to import it in RStudio, I get the following error:
dbot=import("debot")
Error in py_module_import(module, convert = convert) :
ImportError: No module named debot
I am on macOS Sierra version 10.12.6 and installed python 3.6 through Anaconda. I have also tried giving the path to python as:
path_to_python <- "/anaconda/bin/python3.6"
use_python(path_to_python)
When I run python from a terminal, I get:
Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Not sure if the path to python is correct.
Ok, did some more digging around and discovered that reticulate still refers to my older python path for python 2.7 which came as default with my Macbook. When I run py_config(), this is what I get:
python: /usr/bin/python
libpython: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome: /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Feb 7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
No matter what I try but I can't get reticulate to look at the correct path where the module has been installed using the use_python() function. I do believe this is an issue with reticulate. Any ideas what my next steps should be?
After reading this I finally figured out. I think before calling any other function from the reticulate package, it is imperative to specify the path to python to use. Hence the order I am following now is:
library(reticulate)
path_to_python <- "/anaconda/bin/python"
use_python(path_to_python)

strange with downloading modules python 3.5

I have used miniconda and pip to download modules such as matplotlib. The modules works fine when I work in command prompt, but doesn't work when I try to import in my IDLE 3.5 version
It's possible that your command prompt is using a different version of Python. I know that may not be the case, but there is a difference between python, python2, python3, and even more changes in a virtualenv.
In your command prompt (where the module works), type in python, and try to import your module. If it works, check what version of you are using.
For instance, here is what happens when I type in python3 into my terminal.
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
From that, you can see I am using Python 3.4.3.
Now in IDLE, confirm that the versions match, if they do not, then you can work to solving the problem.
Problem still persisting?
You may have two versions (somehow) in different locations. Open up the command prompt and IDLE and type these 3 commands in each
import sys
sys.version
sys.path
Make sure sys.path is the same in both.
I hope I helped!

No module named igraph - Error

I am using anaconda on mac-osx and have installed python-igraph. Currently not being able to import igraph.
Below is the error shown:
Python 2.7.12 |Anaconda 4.1.1 (x86_64)|
import igraph ----
ImportError: No module named igraph
It is present in this path - /Users/pc_name/anaconda/lib/python2.7/site-packages and I find only python_igraph-0.7.1.post6-py2.7.egg-info file.
I tried many things possible which are available on the other questions here at stack overflow. How can I solve this problem?
I used the following command and it worked for me in Python 3.7
pip install python-igraph
The detail about the package and its installation can be found
https://igraph.org/python/
You haven't mentioned how you installed python-igraph so it's hard to say anything. But I'm pretty sure that this package works nicely.
1)While in the python-igraph-master directory on my computer run the following:
conda install -c marufr python-igraph
2)In a new terminal window kick start python:
$python
Python 2.7.13 |Anaconda 4.3.1 (x86_64)| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import igraph
>>>
I hope this helps

Categories

Resources