gsutil no longer works? - python

I've been using gcloud and gsutil for a while but now suddenly for any gsutil command I run I get errors:
Traceback (most recent call last):
File "/Users/julian/google-cloud-sdk/bin/bootstrapping/gsutil.py", line 12, in
import bootstrapping
File "/Users/julian/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 22, in
from googlecloudsdk.core.credentials import store as c_store
File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/credentials/store.py", line 27, in
from googlecloudsdk.core import http
File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/http.py", line 31, in
from googlecloudsdk.core.resource import session_capturer
File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/resource/session_capturer.py", line 32, in
from googlecloudsdk.core.resource import yaml_printer
File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/resource/yaml_printer.py", line 17, in
from googlecloudsdk.core.resource import resource_printer_base
File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_printer_base.py", line 38, in
from googlecloudsdk.core.resource import resource_projector
File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_projector.py", line 34, in
from google.protobuf import json_format as protobuf_encoding
ImportError: cannot import name json_format
I tried gcloud update and gcloud reinstall but still get same problem. Is there a conflict with the python installation? Any other ideas?

You can also fix this error by updating to the latest version of protobuf. Then you don't have to downgrade gcloud.
pip install protobuf --upgrade

The issue occurs when you have google protobuf package installed.
You can work around the problem either by using older version by running
gcloud components update --version 175.0.0
or by removing google protobuf package the python installation.
pip remove protobuf
If you do not want to do either of these, they can install a separate version of 2.7 python (without protobuf) and set CLOUDSDK_PYTHON=/path/to/python environment variable.
Also next release of cloud sdk should have this fix.

I had the same issue. I am using a mac.
Looking into /usr/local/lib/python2.7/site-packages i found a homebrew protobuf link.
I removed it with "rm homebrew-protobuf.pth"
Then gsutil started working.

For CentOS 7.5 (probably earlier as well) using the Google Cloud SDK rpm install, removing the protobuf-python package yum remove protobuf-python will solve this.

I wound up fixing this on my Mac by updating the homebrew install of protobuf:
$ brew upgrade protobuf
...
==> Upgrading 1 outdated package, with result:
protobuf 2.6.1 -> 3.6.0
...
See this issue on the gsutil GitHub repo.

Related

Unable to Pip Install PyMeenus using local package [duplicate]

I setup a new Debian 10 (Buster) instance on AWS EC2, and was able to install a pip3 package that depended on netifaces, but when I came back to it the next day the package is breaking reporting an error in netifaces. If I try to run pip3 install netifaces I get the same error:
~$ pip3 install netifaces
Collecting netifaces
Using cached https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 20, in <module>
from setuptools.dist import Distribution, Feature
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 35, in <module>
from setuptools.depends import Require
File "/usr/lib/python3/dist-packages/setuptools/depends.py", line 7, in <module>
from .py33compat import Bytecode
File "/usr/lib/python3/dist-packages/setuptools/py33compat.py", line 55, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
HTMLParser().unescape was removed in Python 3.9. Compare the code in Python 3.8 vs Python 3.9.
The error seems to be a bug in setuptools. Try to upgrade setuptools. Or use Python 3.8.
I was facing this issue in PyCharm 2018. Apart from upgrading setuptools as mentioned above, I also had to upgrade to PyCharm 2020.3.4 to solve this issue. Related bug on PyCharm issue tracker: https://youtrack.jetbrains.com/issue/PY-39579
Hope this helps someone avoid spending hours trying to debug this.
I had python3.6 and related packages through deb management.
Needed python3.9 for side project and the solution to fix pip and AttributeError: 'HTMLParser' object has no attribute 'unescape'
was to update pip for python3.9 locally for one user:
python3.9 -m pip install --upgrade pip
now installing python3.9 version of the pip-packages work:
python3.9 -m pip install --target=~/.local/lib/python3.9/site-packages numpy
Downgrading to any older python3 version is not the solution and most of the time upgrading setuptools won't fix the issue. The proper solution that worked for me to work with pip using python3.9 is the following on Ubuntu18:
locate /usr/lib/python3/dist-packages/setuptools/py33compact.py33
and change
# unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape) # comment out this line
unescape = getattr(html, 'unescape', None)
if unescape is None:
# HTMLParser.unescape is deprecated since Python 3.4, and will be removed
# from 3.9.
unescape = html_parser.HTMLParser().unescape

ModuleNotFoundError: No module named 'cryptography'

these are the Error messages I am geeting on running any of my project modules.
Traceback (most recent call last):
File "C:\Users\hsnl\BlockchainCodesTutor\Wallet.py", line 3, in <module>
import Transactions
File "C:\Users\hsnl\BlockchainCodesTutor\Transactions.py", line 2, in <module>
import Signatures
File "C:\Users\hsnl\BlockchainCodesTutor\Signatures.py", line 2, in <module>
import cryptography
ModuleNotFoundError: No module named 'cryptography'
I have already installed the cryptography module and was working perfectly until today I start getting this message that " No module named 'cryptography'".
I have again installed the cryptography as well as pip package but still showing the same error.
There might be loose versions running on your system. Please try the following:
python -m pip uninstall cryptography
python -m pip install cryptography
You can also check out this with python -m to make sure you are not using a loose pip.
You might not have cryptogtaphy installed correctly. I see you are using windows. Open commandline as an administrator and run pip install cryptography again. Enshure that the installation finishes without any errors and consider to restart your python interpreter after installation.
For further help you should post more details like the output of pip and your code leading to the error, so a more detailed answer for your problem can be given.
Try download cryptography whl from here.
Then use pip install cryptography-XXX.whl
For example:
pip install cryptography-3.3.1-cp36-abi3-win_amd64.whl
And now just supports python2.7 and python3.6.

no module librepo after installing pytorch on fedora27

I had to install pytorch with conda, and next I had this error when trying to upgrade system :
sudo dnf upgrade
Traceback (most recent call last):
File "/bin/dnf", line 57, in <module>
from dnf.cli import main
File "/usr/lib/python3.6/site-packages/dnf/__init__.py", line 31, in <module>
import dnf.base
File "/usr/lib/python3.6/site-packages/dnf/base.py", line 26, in <module>
from dnf.comps import CompsQuery
File "/usr/lib/python3.6/site-packages/dnf/comps.py", line 29, in <module>
import dnf.util
File "/usr/lib/python3.6/site-packages/dnf/util.py", line 32, in <module>
import librepo
ModuleNotFoundError: No module named 'librepo'
I saw some answer that uses yum-deprecated for re install python, but it seems I don't have it on my machine. I don't want to reinstall linux another time, and I'm searching for kind an answer for that problem.
When installing pytorch via conda, it also installed cuda. Maybe it can be a problem ?
Before this, I remember (not sure, but kind of) I was running with python2.7 by default, and now it is python 3.6..
First the magic one-liner to fix things:
echo 'import sys;sys.path += ["/usr/lib64/python3.6/site-packages/", "/usr/lib64/python3.6/"]' | sudo tee /usr/lib/python3.6/site-packages/lib64.pth
I got the same error after using conda to install jupyterlab. For some reason conda installed its own version of python which shadows fedora's one. Conda's python searches libraries from /usr/lib/ while fedora's also searches /usr/lib64/. On most linux distros /usr/lib/ is a link for /usr/lib64/ or the other way so either one can be used. librepo is installed in /usr/lib64/.
My conclusions:
Fedora is not completely compatible with conda.
Fedora bug reports get closed as duplicate with links to obviously unrelated reports.
I have stumbled upon the same issue in Fedora 28. I used anaconda as root to update packages system wide, and this broke dnf with the message
ModuleNotFoundError: No module named 'librepo'
yum-deprecated did not work, although Fedora installed it for me after automatically querying for it (a bit strange that this worked since dnf and yum did not work).
In order to fix the issue, I deleted the existing libpython, downloaded the python3 and python3-lib rpms from rpmfind, and installed the new rpms
rm -rf /usr/lib/libpython3*.*
rpm -iv --replacepkgs python3-3.6.6-1.fc28.x86_64.rpm
rpm -iv --replacepkgs python3-libs-3.6.6-1.fc28.x86_64.rpm
Now I know it is better to use pip than anaconda system wide.

Error installing paramiko using pip

I am trying to install paramiko using pip. It shows the following long list of error messages after installation. The message here Details here.
Running pip freeze show the paramiko package on the installation list but it is not working.
Trying to run a simple paramiko program shows following error again
Traceback (most recent call last):
File "paramikoBasic.py", line 1, in <module>
import paramiko
File "/home/tara/taraproject/scripttest/paramiko_test/myenv/local/lib/python2.7/site-packages/paramiko/__init__.py", line 30, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/home/tara/taraproject/scripttest/paramiko_test/myenv/local/lib/python2.7/site-packages/paramiko/transport.py", line 33, in <module>
from cryptography.hazmat.backends import default_backend
ImportError: No module named cryptography.hazmat.backendsled
I even tried to install cryptography separately but that even didn't solve the problem. Installed libffi too but that also didn't work out.
I am guessing you are using ubuntu since it's a common problem
The cffi module is dependent on libffi and libffi-dev.
If you search for current version using
apt-cache search libffi
you should be able to get latest version.
Currently you can install as
sudo apt-get install libffi6 libffi-dev
Also you need to install python-dev and crypto packages as logs indicates.
Credit: https://gist.github.com/tchalvak/a230f8b759875748240d
Cheers

how to add json library

i am new to python, on my Mac, when i issue command
User:ihasfriendz user$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
import json
ImportError: No module named json
I get error on json. how to add this library? i'm using 2.5 (the default came with leopard)
You can also install simplejson.
If you have pip (see https://pypi.python.org/pypi/pip) as your Python package manager you can install simplejson with:
pip install simplejson
This is similar to the comment of installing with easy_install, but I prefer pip to easy_install as you can easily uninstall in pip with "pip uninstall package".
AFAIK the json module was added in version 2.6, see here. I'm guessing you can update your python installation to the latest stable 2.6 from this page.
You can also install json-py from here http://sourceforge.net/projects/json-py/

Categories