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.
Related
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
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.
My issue is possibly similar to link
but thought I'd ask jic. I'm on osx and trying to use jedi-vim. I installed jedi using pip and then jedi-vim by cloning into the dir that my vim config uses for loading packages. this one for reference. When I start vim with a python program I get the "Please install Jedi if..." message. I cloned vim 74 and configured with +python and +conceal. After still getting the error I looked into the code and found it was an import error.
As an aside, this isn't the best help message. Better might be "Unable to import jedi. Have you installed Jedi?"
I tried import jedi from within vim, as :python import jedi
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0- py2.7.egg/jedi/__init__.py", line 41, in <module>
from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0 py2.7.egg/jedi/api/__init__.py", line 16, in <module>
from jedi.parser import Parser, load_grammar
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0-py2.7.egg/jedi/parser/__init__.py", line 21, in <module>
from jedi.parser import tree as pt
ImportError: cannot import name tree
If this is a build issue, is there a good reference for building vim on mac?
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.
I had to ask this again, because a related question solves the problem when there is no virtualenv involved.
Now I have more than one virtualenv that I would like to package in executables using cx_Freeze. I run my cx_Freeze setup file normally using virtualenv python interpreter, but then when I try to execute my program, pytz doesn't find the files, probably because if you see the error below, it is searching them in the original directory of virtualenv where they were located. I checked the time zone files are located correctly into the zip file.
This is the error message I get when trying to run my bundled program:
cserpell#e431:~/src/build/exe.linux-x86_64-2.7$ ./validate
/home/cserpell/src/build/exe.linux-x86_64-2.7/library.zip/distutils/__init__.py:14: UserWarning: The virtualenv distutils package at %s appears to be in the same location as the system distutils?
Traceback (most recent call last):
File "/home/cserpell/src/virtualenvtest/local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
exec(code, m.__dict__)
File "scripts/validate.py", line 9, in <module>
File "/home/cserpell/src/scripts/script.py", line 15, in <module>
from common import time_util
File "/home/cserpell/src/common/time_util.py", line 31, in <module>
SCL_TZ = pytz.timezone('America/Santiago')
File "/home/cserpell/src/virtualenvtest/local/lib/python2.7/site-packages/pytz/__init__.py", line 180, in timezone
raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'America/Santiago'
I found the answer myself. The only thing needed was to install setuptools in my virtualenv. For the record, it is very strange that I installed it using pip in the virtualenv, but then when I run pip list or pip freeze, it doesn't show setuptools as requirement, though it is for the cx freeze script.