Python pip doesn't work on Linux mint - python

I have had this error for a year now and still can't find a solution. I am using Linux Mint 17.3 Every time I try to install something using pip, I get a bunch of exceptions.
$ pip install -U scikit-learns
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 272, in run
with self._build_session(options) as session:
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 933, in _get_lsb_release_info
raise subprocess.CalledProcessError(code, cmd, stdout)
CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/__init__.py", line 233, in main
return command.main(cmd_args)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 933, in _get_lsb_release_info
raise subprocess.CalledProcessError(code, cmd, stdout)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1
The "Command 'lsb_release -a' returned non-zero exit status 1" always popped up. I have installed multiple versions of python and tried deleting them manually and it still comes up with the same error.
If you can't help me solve this error, how can I uninstall all python files?

When I update Python and pip,I had the problem like this
your can run lsb_release, if your run shell: #lsb_release
It work like:
Traceback (most recent call last): File "/usr/bin/lsb_release", line
28, in import lsb_release ImportError: No module named
'lsb_release'
You can change file (/usr/bin/lsb_release) so the shebang changes from:
#! /usr/bin/python -Es
to:
#! /usr/bin/python2 -Es
where you specify the path /usr/bin/python2 to the old Python binary.

Related

I can't install pip packages and I get traceback error

pip install clipboard
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
status = run_func(*args)
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\req_command.py", line 205, in wrapper
return func(self, options, args)
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\commands\install.py", line 287, in run
session = self.get_default_session(options)
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\req_command.py", line 75, in get_default_session
self._session = self.enter_context(self._build_session(options))
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\req_command.py", line 89, in _build_session
session = PipSession(
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\network\session.py", line 282, in __init__
self.headers["User-Agent"] = user_agent()
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\network\session.py", line 157, in user_agent
setuptools_dist = get_default_environment().get_distribution("setuptools")
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\metadata\__init__.py", line 75, in get_default_environment
return select_backend().Environment.default()
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\metadata\__init__.py", line 63, in select_backend
from . import pkg_resources
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_internal\metadata\pkg_resources.py", line 8, in <module>
from pip._vendor import pkg_resources
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3252, in <module>
def _initialize_master_working_set():
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3235, in _call_aside
f(*args, **kwargs)
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3277, in _initialize_master_working_set
tuple(
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3278, in <genexpr>
dist.activate(replace=False)
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2785, in activate
declare_namespace(pkg)
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2284, in declare_namespace
_handle_ns(packageName, path_item)
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2217, in _handle_ns
loader.load_module(packageName)
File "C:\Users\amin_\AppData\Roaming\Python\Python310\site-packages\pygoogle\google.py", line 113
print """PyGoogle %(__version__)s
^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
WARNING: There was an error checking the latest version of pip.
I suggest you can use pyperclip as it is the same a s clipboard and it is newer.
https://pypi.org/project/pyperclip/
import pyperclip
>>> pyperclip.copy('The text to be copied to the clipboard.')
>>> pyperclip.paste()
'The text to be copied to the clipboard.'
Currently only handles plaintext.
On Windows, no additional modules are needed.
On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os.
On Linux, this module makes use of the xclip or xsel commands, which should come with the os. Otherwise run “sudo apt-get install xclip” or “sudo apt-get install xsel” (Note: xsel does not always seem to work.)
Otherwise on Linux, you will need the gtk or PyQt4 modules installed.
I hope this help. :)

How do I use the 'keyboard' python module in a docker container without an error?

I am trying to use the python module keyboard in a docker container for testing automation that emulates keyboard presses. However, this module continually returns an error in the docker container whereas it works fine in an ubuntu VM.
I have installed different commonly used docker containers and different versions of python. I get the same error. Sadly, google hasn't been as helpful as it usually is here.
Here's an easily reproducible version of what I've done:
docker run -t -d -u root --name docker_container python:3.7
echo $(docker exec -u root docker_container bash -c 'python3 -m keyboard' )
This returns the below error message:
/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py:110: UserWarning: Failed to create a device file using `uinput` module. Sending of events may be limited or unavailable depending on plugged-in devices.
device = aggregate_devices('kbd')
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 106, in start_reading
self.event_queue.put(device.read_event())
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 83, in read_event
data = self.input_file.read(struct.calcsize(event_bin_format))
AttributeError: 'NoneType' object has no attribute 'read'
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 106, in start_reading
self.event_queue.put(device.read_event())
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 83, in read_event
data = self.input_file.read(struct.calcsize(event_bin_format))
AttributeError: 'NoneType' object has no attribute 'read'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/site-packages/keyboard/__main__.py", line 10, in <module>
keyboard.hook(print_event_json)
File "/usr/local/lib/python3.7/site-packages/keyboard/__init__.py", line 459, in hook
append(callback)
File "/usr/local/lib/python3.7/site-packages/keyboard/_generic.py", line 67, in add_handler
self.start_if_necessary()
File "/usr/local/lib/python3.7/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
self.init()
File "/usr/local/lib/python3.7/site-packages/keyboard/__init__.py", line 194, in init
_os_keyboard.init()
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 114, in init
build_tables()
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 73, in build_tables
dump = check_output(['dumpkeys', '--keys-only'], universal_newlines=True)
File "/usr/local/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/usr/local/lib/python3.7/subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'dumpkeys': 'dumpkeys'
From what I understand, it can't access a uinput device / keyboard to be able to dump the keys. Is there a way to virtually simulate a keyboard in the container to allow this to work?
try to install the following:
apt-get install -y kmod kbd
since you need this to get dumpkeys

pip install language-check not working

I get this error when I do pip install language-check:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/j6/yr6zgb4d1w308jkpc27p2t9w0000gn/T/pip-build-ymwzmypp/language-check/setup.py", line 595, in <module>
sys.exit(main())
File "/private/var/folders/j6/yr6zgb4d1w308jkpc27p2t9w0000gn/T/pip-build-ymwzmypp/language-check/setup.py", line 590, in main
run_setup_hooks(config)
File "/private/var/folders/j6/yr6zgb4d1w308jkpc27p2t9w0000gn/T/pip-build-ymwzmypp/language-check/setup.py", line 561, in run_setup_hooks
language_tool_hook(config)
File "/private/var/folders/j6/yr6zgb4d1w308jkpc27p2t9w0000gn/T/pip-build-ymwzmypp/language-check/setup.py", line 584, in language_tool_hook
download_lt()
File "/private/var/folders/j6/yr6zgb4d1w308jkpc27p2t9w0000gn/T/pip-build-ymwzmypp/language-check/download_lt.py", line 117, in download_lt
version = get_newest_possible_languagetool_version()
File "/private/var/folders/j6/yr6zgb4d1w308jkpc27p2t9w0000gn/T/pip-build-ymwzmypp/language-check/download_lt.py", line 81, in get_newest_possible_languagetool_version
universal_newlines=True)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 336, in check_output
**kwargs).stdout
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/bin/java', '-version']' returned non-zero exit status 1.
I've looked at this question python pip install error language_check and followed the instructions to install python setup.py install and I get this:
Traceback (most recent call last):
File "setup.py", line 595, in <module>
sys.exit(main())
File "setup.py", line 590, in main
run_setup_hooks(config)
File "setup.py", line 561, in run_setup_hooks
language_tool_hook(config)
File "setup.py", line 584, in language_tool_hook
download_lt()
File "/Users/allyzamarquez/ben/language_check/language-check/download_lt.py", line 117, in download_lt
version = get_newest_possible_languagetool_version()
File "/Users/allyzamarquez/ben/language_check/language-check/download_lt.py", line 81, in get_newest_possible_languagetool_version
universal_newlines=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 573, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/usr/bin/java', '-version']' returned non-zero exit status 1
Java 8 must be used until language-check fixes their installer script:
sudo apt install openjdk-8-jdk
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
pip install language-check

Issue after pip update to version 9.0.1 (on Ubuntu)

I have a python 2.7.12 installed on ubuntu 10.04. I have updated pip from 8.1.2 to the last version (9.0.1) but now when I run pip I get this error:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 233, in main
return command.main(cmd_args)
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distro.py", line 933, in _get_lsb_release_info
raise subprocess.CalledProcessError(code, cmd, stdout)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1
Any ideas to solve this issue?

pip cant install radiopy

I've tried
pip install radiopy
Traceback:
C:\Users\олег\Downloads>pip install radiopy
Collecting radiopy
Using cached radio
py-0.6.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\29F0~1\AppData\Local\Temp\pip-build-blxa2oob\radiopy\setup.py, line 23, in <module>
version=get_version('radio.py'),
File "C:\Users\29F0~1\AppData\Local\Temp\pip-build-blxa2oob\radiopy\setup.py
return __version__
NameError: name '__version__' is not defined
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\29F0~1\AppData\Local\Temp\pip-build-blxa2oob\radiopy\
I've also tried:
easy_install radiopy
Traceback:
File "c:\python34\lib\site-packages\setuptools\sandbox.py", line 168, in save_modules
saved_exc.resume()
File "c:\python34\lib\site-packages\setuptools\sandbox.py", line 143, in resume
six.reraise(type, exc, self._tb)
File "c:\python34\lib\site-packages\pkg_resources\_vendor\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "c:\python34\lib\site-packages\setuptools\sandbox.py", line 156, in save_modules
yield saved
File "c:\python34\lib\site-packages\setuptools\sandbox.py", line 197, in setup_context yield
File "c:\python34\lib\site-packages\setuptools\sandbox.py", line 246, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "c:\python34\lib\site-packages\setuptools\sandbox.py", line 276, in run return func()
File "c:\python34\lib\site-packages\setuptools\sandbox.py", line 245, in runner
_execfile(setup_script, ns)
File "c:\python34\lib\site-packages\setuptools\sandbox.py", line 47, in _execfile
exec(code, globals, locals)
File "C:\Users\29F0~1\AppData\Local\Temp\easy_install-laprrvio\radiopy-0.6\setup.py", line 23, in <module>
File "C:\Users\29F0~1\AppData\Local\Temp\easy_install-laprrvio\radiopy-0.6\setup.py", line 19, in get_version
NameError: name '__version__' is not defined
Lately,
C:\Users\олег>pip install C:\\Users\\олег\\Downloads\\radiopy-0.6.tar.gz
Traceback:
C:\Users\олег>pip install C:\\Users\\олег\\Downloads\\radiopy-0.6.tar.gz
Processing c:\users\олег\downloads\radiopy-0.6.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\29F0~1\AppData\Local\Temp\pip-8evw0uk0-build\setup.py", line 23, in <module>
version=get_version('radio.py'),
File "C:\Users\29F0~1\AppData\Local\Temp\pip-8evw0uk0-build\setup.py", line 19, in get_version
return __version__
NameError: name '__version__' is not defined
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\29F0~1\AppData\Local\Temp\pip-8evw0uk0-build\
How can I solve this?
The module seems to support Python 2 only. The setup.py contains a very dubious hack to evaluate the __version__ variable:
def get_version(filename):
"""Extract __version__ from file by parsing it."""
with open(filename) as fp:
for line in fp:
if line.startswith('__version__'):
exec(line)
return __version__
What this does is to find a line that starts with __version__, namely __version__ = '0.6', and then execute it as dynamic code with exec, which works. However in Python 3 this doesn't modify local variables and thus __version__ is not defined on the next line.
Even if you fixed this bug, you'd met a countless others as the package is not Python-3-ready at all. The easiest solution would be to use Python 2. But even then I am not too sure if this works correctly on Windows as it is written for the mplayer/mencoder suite, and seems to be very Linux/POSIX minded in its code.

Categories

Resources