Pip does not work after upgrade to ubuntu-16.10 - python-2.7

Running a command alongwith pip gives the following error. Even the command pip -V produces the following error.
I read that the error is due to setuptools version 31.0.0 and it should be lower than 28.0.0. But the version of my setuptools is 26.1.1 and it still gives the same error.
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in
from pip import main
File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 26, in
from pip.utils import get_installed_distributions, get_prog
File "/usr/local/lib/python3.5/dist-packages/pip/utils/__init__.py", line 27, in
from pip._vendor import pkg_resources
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in
#_call_aside
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/usr/local/lib/python3.5/dist-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'

The only solution I could find is reinstalling pip. Run these commands on your terminal
wget https://bootstrap.pypa.io/get-pip.py
sudo -H python get-pip.py --prefix=/usr/local/
However, this works only for pip, not pip3!

Upgrade your setuptools:
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python3
Generally sudo combined with pip is considered harmful, avoid this when your system is not already broken.

Please refer to https://stackoverflow.com/a/48126778/7596504. The problem could be fixed by modifying your /usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py.

Related

error while setting up chromium

i am getting following error while setting up chromium from source code.
when i run gn gen out/Default
gn gen out/Default
ERROR at //build/config/linux/pkg_config.gni:103:17: Script returned non-zero exit code.
pkgresult = exec_script(pkg_config_script, args, "value")
^----------
Current dir: /opt/apps/chromium/chromium_src/src/out/Default/
Command: python -- /opt/apps/chromium/chromium_src/src/build/config/linux/pkg-config.py -s /opt/apps/chromium/chromium_src/src/build/linux/debian_stretch_amd64-sysroot -a x64 nss -v -lssl3
Returned 1.
stderr:
Traceback (most recent call last):
File "/opt/apps/chromium/chromium_src/src/build/config/linux/pkg-config.py", line 232, in <module>
sys.exit(main())
File "/opt/apps/chromium/chromium_src/src/build/config/linux/pkg-config.py", line 139, in main
prefix = GetPkgConfigPrefixToStrip(options, args)
File "/opt/apps/chromium/chromium_src/src/build/config/linux/pkg-config.py", line 80, in GetPkgConfigPrefixToStrip
"--variable=prefix"] + args, env=os.environ)
File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
See //third_party/nss/BUILD.gn:15:3: whence it was called.
pkg_config("system_nss_no_ssl_config") {
^---------------------------------------
See //crypto/BUILD.gn:221:25: which caused the file to be included.
public_configs += [ "//third_party/nss:system_nss_no_ssl_config" ].
I am not able to make out how to fix this.
i followed https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions.md
also referred these
https://groups.google.com/a/chromium.org/forum/#!topic/chromium-os-dev/360e3QsLH-8
https://groups.google.com/a/chromium.org/forum/#!msg/chromium-os-dev/nM7Af-sJP_I/YoqXPgZ0BQAJ
Not able to get much details.
These discussions refer to PKG_CONFIG_LIBDIR but its not clear where to set this value or use it exactly.
Any inputs on what i may be missing ?
I had the same issue resolved it by installing this packages
sudo apt-get update && sudo apt-get install pkg-config
I had the same issue, and I also tried with sudo apt-get update && sudo apt-get install pkg-config as mentioned by #Rajan Palani and many other git issues comments.
But in my case
sudo apt install libpango1.0-dev
sudo apt install libcogl-pango-dev
sudo apt install libjpeg-dev
above commands helps me out to solve the issue
source:
https://programmer.group/how_to_build_chromium_project_for_linux.html

in virtual env, with centos and pip installed, I can't run a pip freeze

I have a program where I dearly need the dependency list, but pip freeze isn't working. I am running CentOS 7 and Python 2.7.5
The program runs on Python 2.4 (which I am doing as an alias in another terminal, yes, I did try the pip freeze from that terminal) and fortran95. I definitely have pip installed. I tried upgrading the Python2.7, but it says it is fine.
The the error from pip is as follows.
[root#localhost rotate6]# pip freeze
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/freeze.py", line 85, in run
for line in freeze(**freeze_kwargs):
File "/usr/lib/python2.7/site-packages/pip/operations/freeze.py", line 47, in freeze
dependency_links
File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 264, in from_dist
req = dist.as_requirement()
File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2562, in as_requirement
return Requirement.parse(spec)
File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2833, in parse
req, = parse_requirements(s)
File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2781, in parse_requirements
yield Requirement(line)
File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2790, in __init__
raise RequirementParseError(str(e))
RequirementParseError: Invalid requirement, parse error at "'-ipap11h'"
This is a known issue. See https://github.com/pypa/pip/issues/3764
The advice there is to try downgrading your version of pip to one that is less strict (some people find 8.1.0 works), or to uninstall the offending package, which appears to be _ipap11helper.

python3.2 + virtualenv - env create failed

I've got a py2.7 project which I want to test under py3.2. For this purpose, I want to use virtualenv. I wanted to create an environment that would run 3.2 version internally:
virtualenv 3.2 -p /usr/bin/python3.2
but it failed. My default python version is 2.7 (ubuntu default settings). Here is virtualenv --version 1.10. The error output is:
Running virtualenv with interpreter /usr/bin/python3.2
New python executable in 3.2/bin/python3.2
Also creating executable in 3.2/bin/python
Installing Setuptools...................................................................................................................................................................................................................................done.
Installing Pip..............
Complete output from command /home/tomasz/Develop...on/3.2/bin/python3.2 setup.py install --single-version-externally-managed --record record:
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, find_packages
File "/usr/lib/python2.7/dist-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/usr/lib/python2.7/dist-packages/setuptools/extension.py", line 2, in <module>
from setuptools.dist import _get_unpatched
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
----------------------------------------
...Installing Pip...done.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2308, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 821, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 963, in create_environment
install_sdist('Pip', 'pip-*.tar.gz', py_executable, search_dirs)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 932, in install_sdist
filter_stdout=filter_install_output)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 899, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/tomasz/Develop...on/3.2/bin/python3.2 setup.py install --single-version-externally-managed --record record failed with error code 1
I don't know what the hell is this syntax error - where does it come from... I know there was a change in try...catch statement syntax between 2.x and 3.x, but should virtualenv throw syntax errors?
I'd be grateful if someone pointed me out if there's something I'm doing wrong or if there is an installation problem on my machine.
To create a Python 3.2 virtual environment you should use the virtualenv you installed for Python 3.2. In your case that would be:
/usr/bin/virtualenv-3.2
You'll have to use a Python 3 version of virtualenv; the version you are using is installing Python 2 tools into a Python 3 virtual environment and these are not compatible.
virtualenv --python=/usr/bin/python3.2 --no-site-packages ENV

Decide which python version to use for pip and easy_install

I have two python versions on my server namely 2.4 and 2.7. It is running RHEL 5.8.
I already have pip and easy_install installed on my server.
When I try to install ipython using easy_install or pip, it gives me an error which probably does not support in python 2.4.
I want to use python 2.7 for both pip and easy_install since I would want to use the latest version of the both.
What should I do to have pip and easy_install use python 2.7. Python 2.4 is installed by default by the system and I do want to keep it.
Python 2.7 is installed at another location.
Below is the traceback both for easy_install and pip. Both end up in the same error. Any kind of help is appreciated.
PIP
ronak#ronak fun $ sudo pip install ipython
Downloading/unpacking ipython
Downloading ipython-0.13.zip (6.4Mb): 6.4Mb downloaded
Running setup.py egg_info for package ipython
Traceback (most recent call last):
File "<string>", line 14, in ?
File "/usr/local/home/ronak/fun/build/ipython/setup.py", line 23
from __future__ import print_function
SyntaxError: future feature print_function is not defined
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in ?
File "/usr/local/home/ronak/fun/build/ipython/setup.py", line 23
from __future__ import print_function
SyntaxError: future feature print_function is not defined
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/ronak/.pip/pip.log
EASY_INSTALL:
ronak#ronak $ sudo easy_install ipython
Searching for ipython
Reading http://pypi.python.org/simple/ipython/
Reading http://ipython.scipy.org
Reading http://ipython.scipy.org/dist
Reading http://ipython.scipy.org/dist/0.8.4
Reading http://ipython.scipy.org/dist/0.9.1
Reading http://ipython.org
Reading http://archive.ipython.org/release/0.12.1
Reading https://github.com/ipython/ipython/downloads
Reading http://ipython.scipy.org/dist/old/0.9
Reading http://ipython.scipy.org/dist/0.10
Reading http://archive.ipython.org/release/0.11/
Reading http://archive.ipython.org/release/0.12
Best match: ipython 0.13
Downloading https://github.com/downloads/ipython/ipython/ipython-0.13.zip
Processing ipython-0.13.zip
Running ipython-0.13/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vgPLN2/ipython-0.13/egg-dist-tmp-GHUgsq
Traceback (most recent call last):
File "/usr/bin/easy_install", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 1712, in main
with_ei_usage(lambda:
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 1700, in with_ei_usage
return f()
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 1716, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib/python2.4/distutils/core.py", line 149, in setup
dist.run_commands()
File "/usr/lib/python2.4/distutils/dist.py", line 946, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.4/distutils/dist.py", line 966, in run_command
cmd_obj.run()
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 211, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 446, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 476, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 655, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 930, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py", line 919, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/sandbox.py", line 61, in run_setup
DirectorySandbox(setup_dir).run(
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/sandbox.py", line 105, in run
return func()
File "/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/sandbox.py", line 64, in <lambda>
{'__file__':setup_script, '__name__':'__main__'}
File "setup.py", line 23
from __future__ import print_function
SyntaxError: future feature print_function is not defined
One way would be:
Open pip/easy_install in text editor
Check top line, it should say
#! /usr/bin/python
Change it to #!path/to/python2.7
You should check this SO question.
You may also want to consider using virtual environment through virtualenv and virtualenvwrapper to manage which version of Python your packages should use.
If you would like to easily install iPython, SciPy, MatPlotLib, etc. by downloading a .dmg, you can try here:
http://www.enthought.com/products/epd_free.php
Or if you have a academic email address:
http://www.enthought.com/products/edudownload.php
sudo /location/to/python2.7 /path/to/pip install ipython
If you have a recent version of pip, you an also try sudo pip-2.7 install ipython

Problems running Cython

I'm trying to run cython with Python2.7 installed using OSX running Mountain Lion but I get the following errors:
Traceback (most recent call last):
File "/usr/local/bin/cython", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: Cython==0.17
How can I fix this?
Thanks!
Probably what happened is that you installed cython with one version of python and are trying to run it with another. Rather than doing the standard
python setup.py build
sudo python setup.py install
Try just switching to root and both building and installing using an explicit version of python:
sudo su
/usr/bin/python setup.py build
/usr/bin/python setup.py install
(Note that this all assumes that you're installing from a source tarball).