gcloud not working after updating manjaro - python

I had some system updates for my manjaro installation and after that I get the following error message when trying to run gcloud:
gcloud components update
Traceback (most recent call last):
File "/home/mani/Downloads/google-cloud-sdk/lib/gcloud.py", line 104, in <module>
main()
File "/home/mani/Downloads/google-cloud-sdk/lib/gcloud.py", line 62, in main
from googlecloudsdk.core.util import encoding
File "/home/mani/Downloads/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/home/mani/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/usr/lib/python3.9/imp.py", line 23, in <module>
from importlib import util
File "/usr/lib/python3.9/importlib/util.py", line 2, in <module>
from . import abc
File "/usr/lib/python3.9/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/usr/lib/python3.9/typing.py", line 26, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/usr/lib/python3.9/re.py", line 124, in <module>
import enum
File "/home/mani/Downloads/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module>
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'
After looking online I found that the problem could be that this version of gcloud doesn't support python3.9 and the recommended solution was to run gcloud components update but that gives the same error. Is there a way I could revert or make the command use an older python version to upgrade itself then go back to the new python 3.9?

As per following GCP official document you can restore your Cloud Shell VM to it's original state by removing the home directory as follows:
ls -a $HOME
sudo rm -rf $HOME
Now in the Cloud Shell click on the three dot menu and restart the VM will create an new VM and home directory will be restore as it's default state.
As you have the issue in your local machine, after researching I have noticed following PIT1 as a bug in Google Issue Tracker. There are few WA for now on the following thread you can apply it accordingly.
There is another PIT2 as a Feature request to add support for python 3.9. Feel free to post there should you have any additional comments or concerns regarding the issue.
Another WA found in the github might be useful for your use case.

Related

I have broken my poetry installation, and I don't know where to begin to fix it

I was using poetry in combination with pyenv for some hobby projects. I created some virtualenvs with pyenv inside some poetry hobby projects. For some reason, I deleted some of these python installs that broke the virtualenvs within these projects and now poetry won't work anymore. I'm getting this message when I try to start poetry. I'm using Linux Mint 20.1:
/home/milkman/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
Traceback (most recent call last):
File "/home/milkman/.poetry/bin/poetry", line 16, in <module>
from poetry.console import main
File "/home/milkman/.poetry/lib/poetry/console/__init__.py", line 1, in <module>
from .application import Application
File "/home/milkman/.poetry/lib/poetry/console/application.py", line 7, in <module>
from .commands.about import AboutCommand
File "/home/milkman/.poetry/lib/poetry/console/commands/__init__.py", line 4, in <module>
from .check import CheckCommand
File "/home/milkman/.poetry/lib/poetry/console/commands/check.py", line 2, in <module>
from poetry.factory import Factory
File "/home/milkman/.poetry/lib/poetry/factory.py", line 18, in <module>
from .repositories.pypi_repository import PyPiRepository
File "/home/milkman/.poetry/lib/poetry/repositories/pypi_repository.py", line 33, in <module>
from ..inspection.info import PackageInfo
File "/home/milkman/.poetry/lib/poetry/inspection/info.py", line 25, in <module>
from poetry.utils.env import EnvCommandError
File "/home/milkman/.poetry/lib/poetry/utils/env.py", line 23, in <module>
import virtualenv
File "/home/milkman/.poetry/lib/poetry/_vendor/py2.7/virtualenv/__init__.py", line 3, in <module>
from .run import cli_run, session_via_cli
File "/home/milkman/.poetry/lib/poetry/_vendor/py2.7/virtualenv/run/__init__.py", line 13, in <module>
from .plugin.activators import ActivationSelector
File "/home/milkman/.poetry/lib/poetry/_vendor/py2.7/virtualenv/run/plugin/activators.py", line 6, in <module>
from .base import ComponentBuilder
File "/home/milkman/.poetry/lib/poetry/_vendor/py2.7/virtualenv/run/plugin/base.py", line 5, in <module>
from backports.entry_points_selectable import entry_points
ImportError: No module named entry_points_selectable
I have no idea where to start to fix this. Anytime I try a command with poetry I get this same message. Can anyone point me in the right direction?
Thank you!
May be you have deleted some library files. You can try removing poetry and all libraries that your app is using. Start fresh installation of poetry.
You can use pip to install and uninstall.
Other wise start a new project from fresh.
It appears you accidentally deleted some of the library's functions. Try just removing it and reinstalling.

Importing pysftp issue

I am facing this error every time I try to import pysftp in my training.py in the ml.azure.com pipelines. I am using Conda to create the environment for the workspace.
Traceback (most recent call last):
File "start_training.py", line 18, in <module>
import pysftp
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/pysftp/__init__.py", line 12, in <module>
import paramiko
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/paramiko/transport.py", line 89, in <module>
from paramiko.dsskey import DSSKey
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/paramiko/dsskey.py", line 37, in <module>
from paramiko.pkey import PKey
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/paramiko/pkey.py", line 31, in <module>
import bcrypt
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/bcrypt/__init__.py", line 25, in <module>
from . import _bcrypt # type: ignore
ImportError: libffi.so.7: cannot open shared object file: No such file or directory
What I tried and failed:
I also tried to import the older version of pysftp which doesn't have dependency on libffi.so,
I tried with several versions of pysftp.
I tried installing the dependencies of pysftp.
I tried installing paramiko separately with current and older version.
I tried installing the bcrypt with current and older version.
I tried installing libffi.so with current and older version.
I tried creating new environments.
I tried by updating conda and pip also.
I tried to create simlink between libffi.so.6 and libffi.so.7 also.
So far, nothing works.
Help needed on this.

Python 2.7 won't load any modules I installed. Will only load native modules that come with Python 2.7

Note: Please don't comment here that Python 2.7 is depreciated. I already know this. I need to get this working first before migrating to 3.x.
On Windows 10, I had installed (and running correctly) both Python 2.7 and Python 3.7. Since I only needed Python 2.7, I uninstalled Python 3.7 (and manually deleted respective packages installed under .\Python37*) as well as the virtual environment directory below. I have no idea if that virtual environment was associated with Python 2.7 or Python 3.7:
C:\Users\MKANET\Envs\MKA.NETT
After I rebooted, to my horror, every time I run a Python 2.7 script, I get a whole bunch of ambiguous traceback errors when trying to import modules I had installed with PIP (for Python 2.7). However, I don't have issues importing the modules like sys, json (packages that come preinstalled with Python 2.7).
When executing script below from Windows command-line:
& C:/Users/MKANET/AppData/Local/Programs/Python/python27/python.exe c:/Users/MKANET/OneDrive/Dev/Projects/Python/test2.py
...I get a bunch of ambiguous traceback errors:.
Traceback (most recent call last):
File "c:/Users/MKANET/OneDrive/Dev/Projects/Python/test2.py", line 3, in <module>
from pypsexec.client import Client
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\pypsexec\client.py", line 8, in <module>
from smbprotocol.connection import Connection, NtStatus
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\smbprotocol\connection.py", line 33, in <module>
from cryptography.hazmat.primitives.ciphers import (
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\primitives\ciphers\aead.py", line 10, in <module>
from cryptography.hazmat.backends.openssl import aead
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\backends\openssl\__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 16, in <module>
from cryptography import utils, x509
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\__init__.py", line 8, in <module>
from cryptography.x509.base import (
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\base.py", line 18, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\extensions.py", line 26, in <module>
from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\general_name.py", line 10, in <module>
from email.utils import parseaddr
File "c:\Users\MKANET\OneDrive\Dev\Projects\Python\email.py", line 11, in <module>
obj = win32com.client.Dispatch("Outlook.Application")
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
UPDATE HUGE CLUE:
This is ONLY happens when executing scripts in the below folder:
C:\Users\Michael\OneDrive\Dev\Projects\Python
If I execute a script in any other folder on my C: Drive, modules load perfectly without errors. I don't know what's different about this folder that causes my modules not load. Maybe, there's a file in this folder that causing this?
Since this issue was limited only to scripts inside the below directory:
C:\Users\Michael\OneDrive\Dev\Projects\Python
I was able to narrow the issue down to a file called, email.py. If I tried to import a module for example, requests; for some odd reason an email.pyc would get created; followed by the import module errors. All I did was rename email.py to mail.py.. and, this whole issue finally stopped.
I have no idea why Python 2.7 is sensitive to that file name, but changing it to something else resolved the issue for me. Maybe, someone could comment on why the file name breaks things; especially when I had a __init__.py in the same directory to import another module.

Python error in Vim when run inside a 3.5.3 virtualenv

I have multiple Python versions installed with pyenv on Ubuntu 16.04. I create virtual environments to work with projects using different versions with pipenv. However, for Python 3.5.x only I get errors like this when I try to edit a file with Vim 8 (installed via the PPA) in an activated virtualenv:
"test.py" 49L, 1434C
Error detected while processing function jedi#init_python[4]..<SNR>48_init_python[27]..jedi#setup_python_imports:
line 25:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/imp.py", line 19, in <module>
from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/importlib/__init__.py", line 57, in <module>
import types
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/home/user/.local/share/virtualenvs/test-AYf6DmHL/lib/python3.5/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
The issue seems to affect all python related Vim plugins. With other Python versions (e.g. 3.6.x, 3.7.x) this does not occur. What may be causing this issue?
Update: It seems that when I run Vim inside a 3.5.x virtualenv, the Vim's interpreter's sys.path gets updated somehow. For example, this is the output of :py3 import sys; print(sys.path) inside a 3.6.0 virtualenv:
['/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5
/dist-packages', '/usr/lib/python3/dist-packages', '_vim_path_']
And this is for 3.5.3:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/imp.py", line 19, in <module>
from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/importlib/__init__.py", line 57, in <module>
import types
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
['/must>not&exist', '/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python35.zip', '/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/li
b/python3.5', '/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/python3.5/plat-x86_64-linux-gnu', '/home/testuser/.local/share/virtualenvs/venv-3.
5-8feRiT5s/lib/python3.5/lib-dynload', '/home/testuser/.pyenv/versions/3.5.7/lib/python3.5', '/home/testuser/.local/share/virtualenvs/venv-3.5-8feRiT5s/lib/pyt
hon3.5/site-packages']
The issue can be reproduced in a ubuntu:16.04 docker container.
Debian Bug report logs - #852163: python3.5-minimal wont configure demonstrates that this error (for Python 3.5 and Python 3.6) is due to another incompatible installation of Python in /usr/local.
Some further digging with another user in #debian who was experiencing this
problem indicated that it was related to a locally installed
/usr/local/bin/python3.5. The stdlib in /usr/lib/python3.5 is picked up by the
/usr/local/bin/python3.5 but is not compatible with it, resulting in the
stacktrace shown.
Removing /usr/local/bin/python3* and all traces of that installation from
/usr/local/lib (plus other associated tools) solved this problem for the user
I was helping in #debian.
-- Stuart Prescott (link)
The problem is caused by the system installed python, which conflicts with personally installed python.
It could be the case that other python versions are interfering here. Do you have a PYTHONPATH set?
echo $PYTHONPATH
If it is set you could try to unset it. It's usually not needed when using virtual environments.
Try running python with sudo. I think the python which comes with OS needs to run with admin privilege.

ubuntu ImportError: cannot import name MAXREPEAT

Upgrade to 13.04 has totally messed my system up .
I am having this issue when running
./manage.py runserver
Traceback (most recent call last):
File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/home/rats/rats/local/lib/python2.7/site-packages/django/core/management
/__init__.py", line 4, in <module>
from optparse import OptionParser, NO_DEFAULT
File "/usr/lib/python2.7/optparse.py", line 77, in <module>
import textwrap
File "/usr/lib/python2.7/textwrap.py", line 10, in <module>
import string, re
File "/usr/lib/python2.7/string.py", line 83, in <module>
import re as _re
File "/home/rats/rats/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/home/rats/rats/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/home/rats/rats/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/home/rats/rats/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
this is happening for both the real environment as well as for virtual environment .
i tried removing python with
sudo apt-get remove python
and sadly it has removed everything .
now google chrome does not show any fonts .
i am looking for getting things back to work .
help is needed for proper configuring it again.
If you are using virtualenvwrapper then you can recreate the virtualenv on top of the existing one (with no environment currently active):
mkvirtualenv <existing name>
which should pull in the latest (upgraded) python version from the system and fix any mismatch errors.
You don't need to recreate the environment.
You can upgrade the virtualenv running this command:
virtualenv /PATH/TO/YOUR_OLD_ENV
YOUR_OLD_ENV folder will be properly upgraded to the version 2.7.4.
I have just solved that problem on my machine.
The problem was that Ubuntu 13.04 use python 2.7.4. That makes conflict with the Python version of the virtualenv.
What I do was to re-create the virtualenv with the new version of python. I think it's the simplest way, but you can try to upgrade the python version without re-creating all of the virtualenv.

Categories

Resources