I am on OS X 10.11.2, Anaconda Python 2.7.10.
I was installing some dependencies, and suddenly, my conda command started not working at all. Many people suggest conda install python=2.7.10 but when I try that (or any command, even just conda) I get:
Traceback (most recent call last): File
"/Users/Can/anaconda/bin/conda", line 5, in
sys.exit(main()) File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/main.py",
line 106, in main
from conda.cli import conda_argparse File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/conda_argparse.py",
line 16, in
from conda.cli.find_commands import find_commands, find_executable File
"/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/find_commands.py",
line 9, in
from conda.utils import memoized File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/utils.py", line
10, in
import tempfile File "/Users/Can/anaconda/lib/python2.7/tempfile.py", line 32, in
import io as _io File "/Users/Can/anaconda/lib/python2.7/io.py", line 51, in
import _io ImportError: dlopen(/Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so, 2):
Symbol not found: __PyCodecInfo_GetIncrementalDecoder Referenced
from: /Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so Expected
in: dynamic lookup
How can I repair conda, without using conda itself (as I can't)?
UPDATE: I've completely uninstalled and reinstalled Anaconda. It still gives the same error. I've tried pip and it also fails with the same error. I verify it's Anaconda's pip as which pip returns /Users/Can/anaconda2/bin/pip. Why is Anaconda broken?
I had the same issue, it is successfully fixed by just replacing the _io.so file.
sudo find / -name _io.so
copy the path of the _io.so file which DOES NOT belong to python-2.7.11. For example, copy the path of _io.so which is under python-2.7.5:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Replace the '/Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so' file with the _io.so that you just found.
cp /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so /Users/Can/anaconda/lib/python2.7/lib-dynload/
Then it will work.
Related
I installed canopy from the .sh file provided from the link of the Enthought canopy site and then ran the following command after cd into the Canopy directory.
Ashish#LoneWarrior Canopy]$ ./canopy
Subprocess output:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64 /lib/python2.7/site-packages/pyface/gui.py", line 20, in <module>
from .toolkit import toolkit_object
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 99, in <module>
_init_toolkit()
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 65, in _init_toolkit
be = import_toolkit(ETSConfig.toolkit)
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 58, in import_toolkit
__import__(be + 'init')
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/ui/qt4/init.py", line 18, in <module>
from pyface.qt import QtCore, QtGui, qt_api
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/qt/QtGui.py", line 8, in <module>
from PySide.QtGui import *
This is the main error : ZLIB_1.2.9 not found.
ImportError: /home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/bin/../lib/libz.so.1: version `ZLIB_1.2.9' not found (required by /lib64/libpng16.so.16)
I have tried changing the python default to 3 but still it is not working.
I presume the problem is on an Arch-based distribution. The temporary solution in this case is to downgrade libpng to 1.6.28 (this worked in my case). If you don't have it in your cache (`/var/cache/pacman/pkg'), you can download it from https://archive.archlinux.org/packages/l/libpng/
Then, following https://wiki.archlinux.org/index.php/downgrading_packages run in the directory with the downloaded file
# pacman -U libpng-1.6.28-1-x86_64.pkg.tar.xz
(with the correct architecture, of course)
Don't forget to list libpng in /etc/pacman.conf among ignored packages to prevent upgrading. Look for the [options] section and add IgnorePkg = libpng.
Improtant. Keep in mind that downgrading packages is not harmless, therefore, this is only a temporary solution.
The problem is that the libz file in the canopy environment is not compatible with the ZLIB installed in your system.
For a quick fix: just copy the libz.so.1 file from lib directory to your canopy environment.
In my case it was
$ cp /usr/lib/libz.so.1 path-to-Canopy-install-directory/appdata/canopy-2.1.6.3665.rh6-x86_64/lib/libz.so.1
Conda of my friend stopped to work after intensive attempt to install FEniCS DOLFIN. The Anaconda had been installed in the friend's $HOME/anaconda directory (with the directory added to the $PATH). Removal of the directory and installation in a new location have not solved the problem:
$ conda info
Traceback (most recent call last):
File "/home/user/anaconda2/bin/conda", line 4, in <module>
import conda.cli
File "/home/user/anaconda2/lib/python2.7/site-packages/conda/cli/__init__.py", line 8, in <module>
from .main import main # NOQA
File "/home/user/anaconda2/lib/python2.7/site-packages/conda/cli/main.py", line 46, in <module>
from ..base.context import context
File "/home/user/anaconda2/lib/python2.7/site-packages/conda/base/context.py", line 20, in <module>
from ..common.url import urlparse, path_to_url
File "/home/user/anaconda2/lib/python2.7/site-packages/conda/common/url.py", line 17, in <module>
from requests.packages.urllib3.util.url import parse_url
ImportError: No module named packages.urllib3.util.url
However /home/user/anaconda2/lib/python2.7/site-packages/requests/packages/urllib3/util/url.py DOES EXIST.
I have tried to inspect the sys.path (both in ipython and python). The result is:
['',
'/home/user/anaconda2/bin',
'/usr/lib/python2.7/dist-packages',
'/home/user/anaconda2/lib/python27.zip',
'/home/user/anaconda2/lib/python2.7',
'/home/user/anaconda2/lib/python2.7/plat-linux2',
'/home/user/anaconda2/lib/python2.7/lib-tk',
'/home/user/anaconda2/lib/python2.7/lib-old',
'/home/user/anaconda2/lib/python2.7/lib-dynload',
'/home/user/.local/lib/python2.7/site-packages',
'/home/user/anaconda2/lib/python2.7/site-packages',
'/home/user/anaconda2/lib/python2.7/site-packages/Sphinx-1.4.6-py2.7.egg',
'/home/user/anaconda2/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg',
'/usr/lib/python2.7/dist-packages/IPython/extensions']
Note the 3rd (/usr/lib/python2.7/dist-packages) and last (/usr/lib/python2.7/dist-packages/IPython/extensions) element of the list. I suspect it to be the cause of trouble since in sys.path of my (working fine) Anaconda there is no reference to /usr/lib.
Also other Anaconda tools of my friend seems to be affected:
$ ~/anaconda2/bin/pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python2.7/dist-packages
Cleaning up...
I have found similar (unanswered) question conda missing requests.packages.urllib3.util.url but it is unclear, what is the content of sys.path there.
There is also How to fix ImportError: No module named packages.urllib3? - but Anaconda is not mentioned there.
[EDIT]
The problem is NOT systemwide - at my account I have installed Anaconda succesfully and it works fine. No suspicious entries in sys.path too.
[EDIT]
Desperate times call for desperate measures. The problem has been fixedwalked arround with removal of friend's home directory.
I'm learning python and I'm using OS X. I've installed anaconda 3 and set up env called testenv with python 3.5. Then I activated recently created env and installed several packages such as numpy, pandas and opencv3. Nevertheless, when I run python shell and type "import numpy" I get the following errors:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
Referenced from: /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
The same happens with other packages.
File "/usr/local/lib/python2.7/site-packages/numpy/init.py", line
180, in
Python is picking up the packages from the system's Python packages and not from the packages installed in your virtualenv i.e. testenv.
Be sure that you have activated the virtualenv with something like:
source testenv/bin/activate
and then try running Python.
And you said you set it up with Python 3.5 but it's picking path with python2.7.
Let me know if that solves your problem.
I solved this problem by simply writing this command:
sudo python3 -m pip install --upgrade numpy
Another possible method to fix it is to eliminate /usr/local/lib/python2.7 in PYTHONPATH
On a Mac.... this is how to do this safely
brew install python3
Lets now add a virtual env called pe35
python3 -m venv ~/pe35
Now lets use the virtualenv
source ~/pe35/bin/activate
If you want a symbol - place this in you .bash_profile
alias pe35='source ~/pe35/bin/activate'
Now to install numpy in your virtualenv
pip install numpy
I can't run pip2, which is installed from its Arch Linux package:
$ pip2
Traceback (most recent call last):
File "/usr/bin/pip2", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 47, in <module>
from pkg_resources.extern.six.moves import urllib, map, filter
ImportError: No module named moves
I reinstalled python2-pip2 and python2-setuptools with no results. This has been a problem for months.
While I don't understand the issue, it is possible to reset it by removing locally (--user) installed packages:
Move all packages installed as the user:
mv ~/.local/lib/python2.7/site-packages ~/site-packages-bak
or try to pinpoint the problematic files. In my case, for some reason I had a python file and its pyc file lying around the site-packages directory and just moving them solved my issue:
mv ~/.local/lib/python2.7/site-packages/six.py ~/six.py-bak
mv ~/.local/lib/python2.7/site-packages/six.pyc ~/six.pyc-bak
Fedora 21, default Python is 2.7, 3.x installed, originally installed iPython, now have also installed Jupyter
When I try to use the Python3 kernel from Jupyter notebook, I get a message saying the kernel has died, attempting restart. Naturally restart never succeeds.
Tried following these 2 terminal commands
ipython kernelspec install-self
ipython3 kernelspec install-self
first command executes without error. second gives this error
ipython3 kernelspec install-self
I used iPython with Python 3 kernel in the past, before installing Jupyter. I don't remember installing ipython3 to do so.
Suggestions how to resolve? I have searched and the above was the only suggestion I found that was not based on using Anaconda.
Also, I do have kernel.json at
~/.ipython/kernels/python3
thank you
UPDATE
last output on terminal when kernel dies
ImportError: No module named 'ptyprocess'
UPDATE2 traceback error
[xxxxx#localhost ~]$ sudo ipython3 kernelspec install-self
Traceback (most recent call last):
File "/bin/ipython3", line 7, in <module>
from IPython import start_ipython
File "/usr/lib/python3.4/site-packages/IPython/__init__.py", line 47, in <module>
from .core.application import Application
File "/usr/lib/python3.4/site-packages/IPython/core/application.py", line 24, in <module>
from IPython.core import release, crashhandler
File "/usr/lib/python3.4/site-packages/IPython/core/crashhandler.py", line 28, in <module>
from IPython.core import ultratb
File "/usr/lib/python3.4/site-packages/IPython/core/ultratb.py", line 116, in <module>
from IPython.utils import path as util_path
File "/usr/lib/python3.4/site-packages/IPython/utils/path.py", line 19, in <module>
from IPython.utils.process import system
File "/usr/lib/python3.4/site-packages/IPython/utils/process.py", line 19, in <module>
from ._process_posix import system, getoutput, arg_split, check_pid
File "/usr/lib/python3.4/site-packages/IPython/utils/_process_posix.py", line 24, in <module>
import pexpect
File "/usr/lib/python3.4/site-packages/pexpect/__init__.py", line 75, in <module>
from .pty_spawn import spawn, spawnu
File "/usr/lib/python3.4/site-packages/pexpect/pty_spawn.py", line 11, in <module>
import ptyprocess
ImportError: No module named 'ptyprocess'
UPDATE3:
after installing ptyprocess with pip3 new error when trying to create notebook with Python 3...No module named 'path'
[I 22:29:26.125 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 1ae58a7d-096b-4dc1-b29a-bee4385e4e9a restarted
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/IPython/__init__.py", line 48, in <module>
from .terminal.embed import embed
File "/usr/lib/python3.4/site-packages/IPython/terminal/embed.py", line 16, in <module>
from IPython.core.interactiveshell import DummyMod
File "/usr/lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 31, in <module>
from pickleshare import PickleShareDB
File "/usr/lib/python3.4/site-packages/pickleshare.py", line 41, in <module>
from path import path as Path
ImportError: No module named 'path'
[W 22:29:29.137 NotebookApp] KernelRestarter: restart failed
I've just been installing python, ipython, upyter and pyspark as a kernel. I run into some troubles that seem to be close to what you are having. Many times that I used "sudo ..." I would get the wrong python version. I think somehow sudo run commands without a shell, so if you have any configuration (path, python version,etc), you may not get it applied when using sudo. Something you could do is to run "sudo python", then see if you can import the module path. Also you could try to run "sudo which python" to make sure it's the right version. I found that even if the user had python 2.7 installed, sudo would use python 2.6. For me the best thing to do was to log in as root and do the installation without sudo...
I have just started learning python with the jupyter notebook, and I came across the same problem you did. An associate found the problem - I had crated a python program random.py and saved it into my Python directory. Since random is also the name of a module that I installed, an error message was generated in the Anaconda prompt window. Please check your directories for .py files named after reserved words and modules.