Python3 pip install git-pre-push-hook - python-3.x

I tried to install the module git-pre-push-hook with:
pip3 install git-pre-push-hook
mkdir test
cd test
git init
touch README.md
install-git-pre-push-hook
But this error is thrown after using the command install-git-pre-push-hook
Any idea why this happens?
Traceback (most recent call last):
File "/home/tim/.local/bin/install-git-pre-push-hook", line 11, in <module>
sys.exit(main())
File "/home/tim/.local/lib/python3.6/site-packages/git_pre_push_hook/install.py", line 18, in main
os.path.abspath(git_dir.strip()), 'hooks', 'pre-push'
File "/usr/lib/python3.6/posixpath.py", line 94, in join
genericpath._check_arg_types('join', a, *p)
File "/usr/lib/python3.6/genericpath.py", line 151, in _check_arg_types
raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components

Related

Building python3 with ROS using vison_opencv: Raise CvBridgeError, "encoding specified as %s but image has incompatible type %s" % (encoding,cv_type)

I am trying to run python3 with ROS. By default ROS melodic is installed with python2.7.
Hence I have installed the python3 using following instructions:
https://dkqhzm2.tistory.com/entry/ImportError-dynamic-module-does-not-define-module-export-function-PyInitcvbridgeboost-in-Xavier-AGX
where I have cloned the cv_bridge src from the following git: which is called vision_opencv
https://github.com/mikejmills/vision_opencv
I also put in my scripts as
#!/usr/bin/env python3
So that it complies in python3 when I did catkin_make
The following error is the trouble with this package:
rrcam#rrcam20220901-001:~/catkin_ws$ rosrun camera_calibration cameracalibrator.py --size 12x8 --square 0.05 image:=/cam1
Traceback (most recent call last):
File "/home/rrcam/catkin_ws/src/camera_calibration/nodes/cameracalibrator.py", line 39, in <module>
from camera_calibration.camera_calibrator import OpenCVCalibrationNode
File "/home/rrcam/catkin_ws/src/camera_calibration/src/camera_calibration/camera_calibrator.py", line 44, in <module>
from camera_calibration.calibrator import MonoCalibrator, StereoCalibrator, Patterns
File "/home/rrcam/catkin_ws/src/camera_calibration/src/camera_calibration/calibrator.py", line 38, in <module>
import cv_bridge
File "/home/rrcam/catkin_ws/devel/lib/python2.7/dist-packages/cv_bridge/__init__.py", line 34, in <module>
exec(__fh.read())
File "<string>", line 1, in <module>
File "/home/rrcam/catkin_ws/src/vision_opencv/cv_bridge/python/cv_bridge/core.py", line 164
raise CvBridgeError, "encoding specified as %s, but image has incompatible type %s" % (encoding, cv_type)
^
SyntaxError: invalid syntax
Not sure what to do.
If I compile only with python2.7 instead of python3 I get error as:
rrcam#rrcam20220901-001:~/catkin_ws$ rosrun camera_calibration cameracalibrator.py --size 12x8 --square 0.05 image:=/cam1
Exception in thread Thread-6:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/home/rrcam/catkin_ws/src/camera_calibration/src/camera_calibration/camera_calibrator.py", line 118, in run
self.function(m)
File "/home/rrcam/catkin_ws/src/camera_calibration/src/camera_calibration/camera_calibrator.py", line 242, in handle_monocular
max_chessboard_speed = self._max_chessboard_speed)
File "/home/rrcam/catkin_ws/src/camera_calibration/src/camera_calibration/calibrator.py", line 954, in __init__
super(MonoCalibrator, self).__init__(*args, **kwargs)
TypeError: super() argument 1 must be type, not classobj
Can someone tell me how to tackle this problem?
You’re trying to use Python2.x code with Python3, which doesn’t work. If you want to use Python3 with ROS you shouldn’t be using Melodic, since it targets 2.x. You can get it to sort of work with Python3, but it’s still not a great idea.
If you want Python3 you should be using the Noetic distro.

I can't install any package with pip anymore,

I've always used pip in installing python packages but for some unexplained reason it just stopped working. I have tried the following but still not working
i upgraded pip
i rolled back pip
-i uninstalled my python distribution and reinstalled/upgraded it. Here is a trace back of the kind of error i get whenever i try
installing a package with pip
OS- windows 10
pip install profanity
Collecting profanity
Using cached https://files.pythonhosted.org/packages/f6/b4/07d53456462e26eee50abcae787c9380c01731ccc0b6c96233770e546989/profanity-1.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "C:\Users\MEME\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 2698, in get_entry_map
ep_map = self._ep_map
File "C:\Users\MEME\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 2669, in __getattr__
raise AttributeError(attr)
AttributeError: _ep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\MEME\AppData\Local\Temp\pip-install-xg7obvs0\profanity\setup.py", line 72, in <module>
['profanity=profanity:main'],
File "C:\Users\MEME\AppData\Local\Programs\Python\Python37\lib\site-packages\setuptools\__init__.py", line 128, in setup
_install_setup_requires(attrs)
File "C:\Users\MEME\AppData\Local\Programs\Python\Python37\lib\site-packages\setuptools\__init__.py", line 117, in _install_setup_requires
(k, v) for k, v in attrs.items()
File "C:\Users\MEME\AppData\Local\Programs\Python\Python37\lib\site-packages\setuptools\dist.py", line 370, in __init__
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
File "C:\Users\MEME\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 645, in iter_entry_points
entries = dist.get_entry_map(group)
File "C:\Users\MEME\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 2701, in get_entry_map
self._get_metadata('entry_points.txt'), self
File "C:\Users\MEME\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 2412, in parse_map
raise ValueError("Entry points must be listed in groups")
ValueError: Entry points must be listed in groups
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\MEME\AppData\Local\Temp\pip-install-xg7obvs0\profanity\

How to fix urllib3 RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22?

I am a new developer and learning to code in Python 3.4.2. I am running Debian linux on a Raspberry Pi3. After the fresh install I did both
sudo apt-get update
and
sudo apt-get upgrade
to get everything up to date.
I am trying to test a section of code which uploads a file to Dropbox:
import dropbox
import urllib3
authkey = (my dropbox dev auth key)
with open('test.csv','rb') as f:
dbx = dropbox.Dropbox(authkey)
dbx.files_upload(f.read(), '/test.csv')
Now, I have no idea if the actual Dropbox code is correct, because I am getting the following error when I run the script in the Python shell:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module>
assert minor >= 21
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/dbtest.py", line 1, in <module>
import dropbox
File "/usr/local/lib/python3.4/dist-packages/dropbox/__init__.py", line 3, in <module>
from .dropbox import __version__, Dropbox, DropboxTeam, create_session # noqa: F401
File "/usr/local/lib/python3.4/dist-packages/dropbox/dropbox.py", line 18, in <module>
import requests
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 61, in <module>
raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!
To me this indicates that I have an issue with my urllib3 install, so I go to the bash shell and type:
sudo pip3 install --update urllib3
And get the exact same error message:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module>
assert minor >= 21
AssertionError
During handling of the above exception, another exception occurred:
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 22, in <module>
import requests, six
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 61, in <module>
raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!
I have other scripts that use Twilio to send SMS messages and they are no longer working either, yielding the same error message referencing urllib3 version issues.
Can anyone help me resolve this issue or point me in the right direction?
Thank you very much.
On Mac try this:
sudo pip install urllib3==1.23
then
sudo pip install requests

Module can be imported from build directory but not from installed directory

This is encountered on Ubuntu 16.04.2, with GCC 5.4.0 and Python 3.5.2. So I built a module and inside the build directory I can easily import it without problem:
➜ build git:(master) ✗ python3 -c "import foo"
➜ build git:(master) ✗
However, when I install the module into install_dir (the module was built with cmake/make and then make install --prefix=$install_dir) and add its location into PYTHONPATH, it doesn't work:
➜ ~ cd
➜ ~ echo $PYTHONPATH
$install_dir/lib/python3.5/site-packages:/usr/local/lib/python3.5/site-packages:
➜ ~ python3 -c "import foo"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "$install_dir/lib/python3.5/site-packages/foo/__init__.py", line 17, in <module>
from . import cpp
File "$install_dir/lib/python3.5/site-packages/foo/cpp/__init__.py", line 43, in <module>
exec("from . import %s" % module_name)
File "<string>", line 1, in <module>
File "$install_dir/lib/python3.5/site-packages/foo/cpp/common.py", line 21, in <module>
_common = swig_import_helper()
File "$install_dir/lib/python3.5/site-packages/foo/cpp/common.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
SystemError: initialization of _common raised unreported exception
Note: naming has been changed to make the case more generous. The funny thing is I ran the same script for 3 different devices with the fresh installed OS, only 1 has this problem (!).
What could be the main cause here that I can investigate further? Or is this something funny caused by Python 3?
Run into this problem today.
The solution for me was:
upgrade petsc (3.7.3->3.7.6) and slepc (3.7.3->3.7.4)
reinstall petsc4py (3.7.0) and slepc4py (3.7.0)

Pycharm failed to install Python packaging tools

I try to make an easy Python gui, therefore I need to import tkinter. This package is available in Python 3, so I need that interpreter, but I can't get it started in Pycharm. It always asks to install packaging tools and then I get the same error everytime and I can't seem to fix it. I get the following:
Executed command:
/tmp/tmpu8m14jqspycharm-management/pip-9.0.1/setup.py install
Error occured:
AttributeError: module 'setuptools.dist' has no attribute 'check_specifier'
Command output:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2237, in resolve
return functools.reduce(getattr, self.attrs, module)
AttributeError: module 'setuptools.dist' has no attribute 'check_specifier'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/tmpu8m14jqspycharm-management/pip-9.0.1/setup.py", line 92, in <module>
cmdclass={'test': PyTest},
File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 272, in __init__
_Distribution.__init__(self,attrs)
File "/usr/lib/python3.5/distutils/dist.py", line 281, in __init__
self.finalize_options()
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 327, in finalize_options
ep.load()(self, ep.name, value)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2239, in resolve
raise ImportError(str(exc))
ImportError: module 'setuptools.dist' has no attribute 'check_specifier'
I already searched some fixes but none actually worked.
Python PIP might not be installed. In Debian based distribution:
sudo apt-get install python3-pip
should solve if you use Python 3.
For Python 2.7x
sudo apt-get install python-pip
Close PyCharm and re-open it.
In this case, it may be possible that python pip (package installer) is not installed. So try installing that first.:
sudo apt-get install python3-pip

Resources