How can I fix a broken pip under anaconda - python

Pip is broken in my anaconda environment. Pip3 is missing and normal pip is broken.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\Scripts\pip-script.py", line 3, in <module>
import pip
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\utils\__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3018, in <module>
#_call_aside
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2578, in activate
declare_namespace(pkg)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2121, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'`
This is the error. Even if I uninstall pip and reinstall it, it still wont work. I thought maybe I could write all packages of the environment in a .yml file and create a new environment which automatically installs all the packages from the .yml. Cloning the environment didnt work. I cant use anything with pip so I cant upgrade pip or anything else. Reinstalling the setuptools didnt work. Any idea how I can fix this? Thank you very much for your help.
EDIT: With Johns help I could solve the problem. I cant accept my own answer in 2 days so I have to keep it open because maybe someone else encounters the same problem.

Try this:
conda install pip
Normal way of reinstalling pip will not fix issues in anaconda environment.

I managed to fix the problem by deleting the pip.exe and pipscript,py from the anaconda installation and setting the pip environment variable to the pip from another python installation.

Related

AttributeError: dlsym(0x7f9163cea8e0, archive_read_open_filename_w): symbol not found [duplicate]

I was playing around with trying to get biopython working and it seems like I broke conda in the process. At this point, the help menu for conda will display, and conda --version returns conda 4.7.5 but anything else including conda info throws an error AttributeError: dlsym(0x1004381c0, archive_read_open_filename_w): symbol not found
This is on Mac OS 10.14.4. Conda was just working and I last used it to install biopython without error conda install -c conda-forge biopython. Running import Bio still resulted in an a ImportError: No module named Bio. So in troubleshooting I ran pip uninstall biopython (which said it successfully uninstalled biopython-1.73) and pip install biopython which returned:
Requirement already satisfied: biopython in /Users/dmattox/anaconda/lib/python2.7/site-packages (1.73)
Requirement already satisfied: numpy in /Users/dmattox/anaconda/lib/python2.7/site-packages (from biopython) (1.13.1)
I then tried installing with conda again conda install -c conda-forge biopython which returned the same error I showed above from conda info. This AttributeError appears anytime I try and use conda for anything now. I've included the traceback below. Any suggestions?
Traceback (most recent call last):
File "/Users/dmattox/anaconda/bin/conda", line 13, in <module>
sys.exit(main())
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/cli/main.py", line 150, in main
return conda_exception_handler(_main, *args, **kwargs)
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 1335, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 1046, in __call__
return self.handle_exception(exc_val, exc_tb)
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 1090, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 1101, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 1171, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/cli/main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/core/index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda/core/package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/conda_package_handling/api.py", line 3, in <module>
from libarchive.exception import ArchiveError as _LibarchiveArchiveError
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/libarchive/__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/libarchive/entry.py", line 6, in <module>
from . import ffi
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/libarchive/ffi.py", line 184, in <module>
c_int, check_int)
File "/Users/dmattox/anaconda/lib/python2.7/site-packages/libarchive/ffi.py", line 95, in ffi
f = getattr(libarchive, 'archive_'+name)
File "/Users/dmattox/anaconda/lib/python2.7/ctypes/__init__.py", line 375, in __getattr__
func = self.__getitem__(name)
File "/Users/dmattox/anaconda/lib/python2.7/ctypes/__init__.py", line 380, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x100548400, archive_read_open_filename_w): symbol not found
got my error fixed by the method from zhihu
Here are the steps how I solve it, Hope it's helpful to you:
The reason caused this error on Mac is Python was installed before, I tried to delete all the python and Anaconda files, and install the anaconda again, then run the conda command successfully.
Delete python from Macintouch->Frameworks->PythonFramework->Versions->3.x
Delete all the records about python and anaconda in .bash_profile(find this hidden file by shift+command+.)
Delete the anaconda navigator in applications
Install the Anaconda again

Unable to use pip3 to install packages

Hey guys I think my pip3 has just hit a snag. Can somebody help me with this.
I ran this command:
pip3 install tensorflow
And it gave this as an output:
This output is not only with tensorflow package but with any package i try to install with pip3.
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/home/het/.local/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/het/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
#_call_aside
File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2121, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
What can be the reason
Edit: pip works just fine but pip3 doesn't work
Try update pip and setuptools
pip3 install --upgrade pip setuptools
Also, the best way is using virtualenv
You are using the wrong syntax. Just try pip install tensorflow in command prompt and everything should run smoothly. I tried at my end and it worked. Refer attached image. See the first few lines and the last few lines.

Python pip returning incomplete read error

quick thing: YES I KNOW THERE IS ANOTHER POST ON THIS, but its answers do NOT solve my issue.
So I installed this package called hangups on my raspberry pi. It ruined my pip installation and gave me the error below. However if you google this error, you will come to a post that does have a solution: re installing pip. I had done this several times; Once reinstalling pip from apt, 2nd time from get-pip.py, last by reinstalling python3. Irregardless, none of these methods solved my error (Oh and i also must mention that i did try the easy_install reinstallation of pip but that fails too). Nothing seems to work. My theory is that some repository somewhere is not updated because the error message points to some ancient version of pip (<= 2) (on my mac pip is at 9 running same version of python 3) and for some reason, pip has this dependency that isnt there just disables my pip binary. I would install them, but (lol) i dont have pip. The error is below. How do I fix this?
please comment if you need more information. Thanks!!!
/usr/local/lib/python3.4/dist-packages/requests/__init__.py:80:
RequestsDependencyWarning: urllib3 (1.22) or chardet (2.3.0) doesn't
match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python3/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name 'IncompleteRead'
Yeah ok so for future reference kids, easy_install does (like pip) have a python 3.x version. Just do sudo easy_install3 -U pip.

Getting an error when trying to create a virtual env

I want to learn django so I tried to create a virtual env and I am getting this error:
mkvirtualenv django
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2881, in <module>
parse_requirements(__requires__), Environment()
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 596, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv==1.8.2
I haven't used python in a while so i'm not sure what the issue is:
virtualenv --version
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2881, in <module>
parse_requirements(__requires__), Environment()
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 596, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv==1.8.2
You're using mkvirtualenv which is a virtualenvwrapper command. You probably do not have virtualenvwrapper installed.
Type virtualenvwrapper in your command line and observe the input. If you get something like command not found, then you should install it first.
You should install it with pip like so pip install virtualenvwrapper.
There are some post-installation steps, the most important one being source /usr/local/bin/virtualenvwrapper.sh that makes commands like mkvirtualenv, rmvirtualenv available.
See virtualenvwrapper's documentation.
Alternatively, you can also just make use of virtualenv. Check that you have it installed like so
virtualenv --version
If you do not, you can install it with pip. Once you have it installed, you can create your virtualenv like so
virtualenv <name> in the directory of your choice.

Pip error when using "pip install ..."

Using OSX El Capitan. Just installed a bunch of pip module and was following a few online tutorials, must have broken something as now I get the following error whenever I try to use pip (although python seems to run fine).
$ pip install pandas
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2837, in <module>
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 451, in _build_master
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 464, in _build_from_requirements
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 639, in resolve
pkg_resources.DistributionNotFound: pip==1.5.6
Any helping fixing would be much appreciated.
Thanks.
Reinstall using easy_install. Close the terminal and reopen. Pip should now work.
Try updating pip first by typing pip install -U pip and the try pip install pandas. I myself use Anaconda/Miniconda. Most of the packages are well handled and the dependencies are taken care of as well by the conda package manager.

Categories