A few hours ago I updated Xcode to the latest version, which caused gcloud and gsutil commands to stop working. For example, a minute before the update finished, the command gsutil -m rsync was working fine.
While writing this question, I noticed I no longer have git working.
Since I'm not a Python guy, can someone please explain to me what the hell happened now? I would love some help.
python -V output is Python 2.7.16.
python3 -V output is Python 3.9.0.
pip -V output is pip 20.2.3 from /Users/<MY_USER>/Library/Python/2.7/lib/python/site-packages/pip (python 2.7)
pip3 -V output is pip 20.2.3 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)
This is what I get for gcloud help:
Traceback (most recent call last):
File "/Users/<MY_USER>/gcloud/sdk/lib/gcloud.py", line 104, in <module>
main()
File "/Users/<MY_USER>/gcloud/sdk/lib/gcloud.py", line 62, in main
from googlecloudsdk.core.util import encoding
File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 23, in <module>
from importlib import util
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 2, in <module>
from . import abc
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 26, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", line 124, in <module>
import enum
File "/Users/<MY_USER>/gcloud/sdk/lib/third_party/enum/__init__.py", line 26, in <module>
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'
And this is what I get for gsutil help:
Traceback (most recent call last):
File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/gsutil.py", line 13, in <module>
import bootstrapping
File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
import setup # pylint:disable=g-import-not-at-top
File "/Users/<MY_USER>/gcloud/sdk/bin/bootstrapping/setup.py", line 57, in <module>
from googlecloudsdk.core.util import platforms
File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/Users/<MY_USER>/gcloud/sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 23, in <module>
from importlib import util
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 2, in <module>
from . import abc
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 26, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", line 124, in <module>
import enum
File "/Users/<MY_USER>/gcloud/sdk/lib/third_party/enum/__init__.py", line 26, in <module>
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'
So after almost a day with nothing, I found a solution: what I needed to do was set an environment variable named CLOUDSDK_PYTHON to /usr/bin/python.
I edited my .zprofile and added:
export CLOUDSDK_PYTHON="/usr/bin/python"
I still have no idea what caused it, so I'll be glad for an explanation if anyone cares to take the time.
Related
Whenever I run a command related to pip, or pip itself, it just returns an exception and it doesn't install anything
Here's the exception info:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/configuration.py", line 27, in <module>
from pip._internal.utils.misc import ensure_dir, enum
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 38, in <module>
from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_vendor/tenacity/__init__.py", line 522, in <module>
from pip._vendor.tenacity._asyncio import AsyncRetrying
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_vendor/tenacity/_asyncio.py", line 19, in <module>
from asyncio import sleep
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/__init__.py", line 21, in <module>
from .base_events import *
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/base_events.py", line 296
future = tasks.async(future, loop=self)
I was running pip commands to install libraries on replit (because upm doesn't work well), but after uninstalling discord.py, it doesn't seem to work properly anymore
from my experience it is much better to use the pip module instead of the executable.
python3 -m pip install --upgrade pip # upgrade pip
python3 -m pip install replit # install the desired module
I am trying to run the quickstart from Google's Vision python library locally. However, when I run python3 quickstart.py I get the following error:
Traceback (most recent call last):
File "/Users/penguin/.../quickstart.py", line 53, in <module>
print(run_quickstart())
File "/Users/penguin/.../quickstart.py", line 25, in run_quickstart
from google.cloud import vision
File "/Users/pengui/anaconda3/envs/vision/lib/python3.9/site-packages/google/cloud/vision/__init__.py", line 18, in <module>
from google.cloud.vision_v1.services.image_annotator.async_client import (
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/google/cloud/vision_v1/__init__.py", line 17, in <module>
from google.cloud.vision_helpers.decorators import add_single_feature_methods
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/google/cloud/vision_helpers/__init__.py", line 16, in <module>
import proto
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/proto/__init__.py", line 15, in <module>
from .enums import Enum
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/proto/enums.py", line 17, in <module>
from google.protobuf import descriptor_pb2
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/google/protobuf/descriptor_pb2.py", line 5, in <module>
from google.protobuf.internal import builder as _builder
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/google/protobuf/internal/builder.py", line 42, in <module>
from google.protobuf import reflection as _reflection
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/google/protobuf/reflection.py", line 51, in <module>
from google.protobuf import message_factory
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/google/protobuf/message_factory.py", line 42, in <module>
from google.protobuf.internal import api_implementation
File "/Users/penguin/anaconda3/envs/vision/lib/python3.9/site-packages/google/protobuf/internal/api_implementation.py", line 104, in <module>
from google.protobuf.pyext import _message
TypeError: bases must be types
What I know is:
This doesn't happen when I run quickstart in the Google CloudShell
I am using the right creds, GOOGLE_APPLICATION_CREDENTIALS=key.json
I am using python 3.9.12 locally
I installed requirements.txt using pip3 (google-cloud-vision==2.7.2)
python3 and pip3 are both in the right /anaconda3/envs/vision path.
My OS is macOS Monterey 12.4
I am not sure at what point in this stack trace that the error is occurring, or how to fix it.
According to #DazWilkin's comment, downgrade the protobuf package as follows.
pip uninstall protobuf
pip install protobuf==3.20.1
It worked just fine for me. tensorflow and protobuf versions were incompatible in my case.
I get this error when I type airflow vesrion command in terminal. i install airflow from pip in virtual environment.
Traceback (most recent call last):
File "/Users/subham.polpagedar/Desktop/celery_task/venv_celery/bin/airflow", line 25, in <module>
from airflow.configuration import conf
File "/Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/airflow/__init__.py", line 42, in <module>
from airflow.models import DAG
File "/Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/airflow/models/__init__.py", line 21, in <module>
from airflow.models.baseoperator import BaseOperator, BaseOperatorLink # noqa: F401
File "/Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 43, in <module>
from airflow.models.dag import DAG
File "/Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/airflow/models/dag.py", line 46, in <module>
from airflow.executors import LocalExecutor, get_default_executor
File "/Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/airflow/executors/__init__.py", line 24, in <module>
from airflow.executors.base_executor import BaseExecutor # noqa
File "/Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/airflow/executors/base_executor.py", line 24, in <module>
import airflow.utils.dag_processing
File "/Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/airflow/utils/dag_processing.py", line 40, in <module>
from setproctitle import setproctitle
ImportError: dlopen(/Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/setproctitle.cpython-37m-darwin.so, 2): Symbol not found: _Py_GetArgcArgv
Referenced from: /Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/setproctitle.cpython-37m-darwin.so
Expected in: flat namespace
in /Users/subham.polpagedar/Desktop/celery_task/venv_celery/lib/python3.7/site-packages/setproctitle.cpython-37m-darwin.so
I faced a similar issue on macos. It turns out it was related to the python installed through brew.
If you can, try to use this version from python official website: https://www.python.org/downloads/
and use your virtual environment base as the version you just downloaded.
Hope it helps
I am trying to use tensorflow for research in my macbook. I use pip3 to install tensorflow in the system (not in virtual environment).
At first, I just want to verify tensorflow can be correctly imported via python3 in terminal. However, sometimes, I got the following problem when importing.
>>>import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cyan/Library/Python/3.5/lib/python/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/cyan/Library/Python/3.5/lib/python/site-packages/tensorflow/python/__init__.py", line 47, in <module>
import numpy as np
File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/Library/Python/2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Python/2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Library/Python/2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Library/Python/2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: dlopen(/Library/Python/2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
Referenced from: /Library/Python/2.7/site-packages/numpy/core/multiarray.so
Expected in: flat namespace in /Library/Python/2.7/site-packages/numpy/core/multiarray.so
This error could only be solved if I ran the following code firstly before python3 execution
unset PYTHONPATH
If I didn't unset PYTHONPATH, I also found errors when checking the version of pip3 using
pip3 --version
The errors are shown as follows.
>> pip3 --version
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 6, in <module>
from pip._internal import main
File "/Library/Python/2.7/site-packages/pip/_internal/__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/Library/Python/2.7/site-packages/http/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
I thought it was so inconvenient to unset PYTHONPATH every time, so is there any solutions for this problem? I also want to import tensorflow in other text editor, such as Sublime and Pycharm, so I was really not sure what to do next.
I tried the same scenario. It is working fine for me. In the first error it seems your python installation is messed up. If you are using python3 in terminal, it should not refer to 2.7 libraries.
Also I dont think you require unset PYTHONPATH everytime. First thing is you dont need to setup PYTHONPATH. It seems the installation got issue.
You using homebrew in mac to install packages. If not I will say use homebrew and it will work as charm. As it adds dependency properly.
Thanks,
Ashish
C:\Users\jesper>pip Traceback (most recent call last): File
"D:\Anaconda3\Scripts\pip-script.py", line 3, in <module>
import pip File "D:\Anaconda3\lib\site-packages\pip\__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog File "D:\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 22, in
<module>
from pip.compat import console_to_str, expanduser, stdlib_pkgs File "D:\Anaconda3\lib\site-packages\pip\compat\__init__.py", line 11,
in <module>
from logging.config import dictConfig as logging_dictConfig File "D:\Anaconda3\lib\logging\config.py", line 30, in <module>
import logging.handlers File "D:\Anaconda3\lib\logging\handlers.py", line 26, in <module>
import logging, socket, os, pickle, struct, time, re File "D:\Anaconda3\lib\socket.py", line 123, in <module>
class socket(_socket.socket): TypeError: __weakref__ slot disallowed: either we already got one, or __itemsize__ != 0
I get this now, and it happened randomly and keeps recurring. I can't use Python at the moment. I tried re-installing the entire conda library and tried different locations for Anaconda. Even tried installing Anaconda for 2.7 and it still didn't work. If someone knows how to fix I'd be in there eternal debt. Thanks!