Installation Failed: pipenv install google-ads (TypeError: expected string or bytes-like object)

Installation Failed: pipenv install google-ads (TypeError: expected string or bytes-like object)

pipenv install google-ads 产生错误:

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
This is likely caused by a bug in google-ads. Report this to its maintainers.
✘ Installation Failed

这就是全部:

% pipenv install google-ads
Creating a virtualenv for this project...
Pipfile: /Users/ralf/code/test_snippets/20-12-10_google_ads/Pipfile
Using /usr/local/bin/python3.9 (3.9.0) to create virtualenv...
⠦ Creating virtual environment...created virtual environment CPython3.9.0.final.0-64 in 325ms
  creator CPython3Posix(dest=/Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/ralf/Library/Application Support/virtualenv)
    added seed packages: pip==20.2.4, setuptools==50.3.2, wheel==0.35.1
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment! 
Virtualenv location: /Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj
Installing google-ads...
Error:  An error occurred while installing google-ads!
Error text: Processing /Users/ralf/Library/Caches/pipenv/wheels/0a/09/22/d4a45ac4200d9c68a5215e554d4181b51af2c01b4f16232b5c/google_ads-8.0.0-py3-none-any.whl
Collecting googleapis-common-protos<2.0.0,>=1.5.8
  Using cached googleapis_common_protos-1.52.0-py2.py3-none-any.whl (100 kB)
Collecting google-auth-oauthlib<1.0.0,>=0.3.0
  Using cached google_auth_oauthlib-0.4.2-py2.py3-none-any.whl (18 kB)
Collecting protobuf<4.0.0,>=3.13.0
  Using cached protobuf-3.14.0-py2.py3-none-any.whl (173 kB)
Collecting google-api-core<2.0.0,>=1.14.0
  Using cached google_api_core-1.23.0-py2.py3-none-any.whl (91 kB)
Processing /Users/ralf/Library/Caches/pipenv/wheels/69/60/81/5cd74b8ee068fbe9e04ca0d53148f28f5c6e2c5b177d5dd622/PyYAML-5.3.1-cp39-cp39-macosx_11_0_x86_64.whl
Requirement already satisfied, skipping upgrade: setuptools>=40.3.0 in /Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj/lib/python3.9/site-packages (from google-ads->-r /var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pipenv-p0t2erav-requirements/pipenv-xefzspt6-requirement.txt (line 1)) (50.3.2)
Collecting grpcio<2.0.0,>=1.33.2
  Using cached grpcio-1.34.0.tar.gz (21.0 MB)

    ERROR: Command errored out with exit status 1:
     command: /Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-install-woj2xbsv/grpcio/setup.py'"'"'; __file__='"'"'/private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-install-woj2xbsv/grpcio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-pip-egg-info-d7h_fmnt
         cwd: /private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-install-woj2xbsv/grpcio/
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-install-woj2xbsv/grpcio/setup.py", line 359, in <module>
        if mac_target and (pkg_resources.parse_version(mac_target) <
      File "/Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj/lib/python3.9/site-packages/pkg_resources/__init__.py", line 113, in parse_version
        return packaging.version.Version(v)
      File "/Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/version.py", line 275, in __init__
        match = self._regex.search(version)
    TypeError: expected string or bytes-like object
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

This is likely caused by a bug in google-ads. Report this to its maintainers.
✘ Installation Failed 

我对 pipenv 了解不多,我只是在使用它 – 到目前为止没有任何问题。现在我从头开始 运行 brew update, brew outdatedbrew upgrade

我如何最好地向其维护者报告,“它”是什么意思,Google Ads 或 Pipenv?还有什么我可以做的吗?

更新:

以下 以下是有关我正在使用的系统的更多信息:

我用 homebrew 安装了 Python 3 然后 pip3 install pipenv.

更新二:

只是 pip(而不是 pipenv)我首先 运行 遇到了同样的错误,但是在 更新 pip 之后,它起作用了美好的。这是我的输入:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install google-ads

更新 3:

我尝试按照 ,在安装 google-ads 包之前更新我的 pipenv 环境中的 pip。这些是我的命令:

pipenv --rm
pipenv shell
pip insall --upgrade pip
exit
pipenv install google-ads

错误消息看起来仍然相似:

Installing google-ads...
Adding google-ads to Pipfile's [packages]...
✔ Installation Succeeded 
Pipfile.lock (16c839) out of date, updating to (f55075)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed! 
ERROR:pip.subprocessor:Command errored out with exit status 1:
 command: /Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-resolver-p0oskrkm/grpcio/setup.py'"'"'; __file__='"'"'/private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-resolver-p0oskrkm/grpcio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-resolver-p0oskrkm/grpcio/pip-egg-info
     cwd: /private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-resolver-p0oskrkm/grpcio/
Complete output (9 lines):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/nc/s6kd50kj3gdg81vhy9qwddkw0000gn/T/pip-resolver-p0oskrkm/grpcio/setup.py", line 359, in <module>
    if mac_target and (pkg_resources.parse_version(mac_target) <
  File "/Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj/lib/python3.9/site-packages/pkg_resources/__init__.py", line 113, in parse_version
    return packaging.version.Version(v)
  File "/Users/ralf/.local/share/virtualenvs/20-12-10_google_ads-S7vGVfKj/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/version.py", line 275, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object
----------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pipenv/resolver.py", line 764, in <module>
    main()
  File "/usr/local/lib/python3.9/site-packages/pipenv/resolver.py", line 758, in main
    _main(parsed.pre, parsed.clear, parsed.verbose, parsed.system, parsed.write,
  File "/usr/local/lib/python3.9/site-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
  File "/usr/local/lib/python3.9/site-packages/pipenv/resolver.py", line 702, in resolve_packages
    results, resolver = resolve(
  File "/usr/local/lib/python3.9/site-packages/pipenv/resolver.py", line 684, in resolve
    return resolve_deps(
  File "/usr/local/lib/python3.9/site-packages/pipenv/utils.py", line 1395, in resolve_deps
    results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
  File "/usr/local/lib/python3.9/site-packages/pipenv/utils.py", line 1108, in actually_resolve_deps
    resolver.resolve()
  File "/usr/local/lib/python3.9/site-packages/pipenv/utils.py", line 823, in resolve
    results = self.resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/piptools/resolver.py", line 180, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/piptools/resolver.py", line 268, in _resolve_one_round
    their_constraints.extend(self._iter_dependencies(best_match))
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/piptools/resolver.py", line 383, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 229, in get_dependencies
    legacy_results = self.get_legacy_dependencies(ireq)
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 350, in get_legacy_dependencies
    results, ireq = self.resolve_reqs(
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 306, in resolve_reqs
    results = resolver._resolve_one(reqset, ireq)
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/legacy_resolve.py", line 339, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/legacy_resolve.py", line 287, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/operations/prepare.py", line 508, in prepare_linked_requirement
    abstract_dist = _get_prepared_distribution(
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/operations/prepare.py", line 95, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/distributions/sdist.py", line 40, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/req/req_install.py", line 564, in prepare_metadata
    self.metadata_directory = self._generate_metadata()
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/req/req_install.py", line 538, in _generate_metadata
    return generate_metadata_legacy(
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/operations/build/metadata_legacy.py", line 115, in generate_metadata
    call_subprocess(
  File "/usr/local/lib/python3.9/site-packages/pipenv/patched/notpip/_internal/utils/subprocess.py", line 242, in call_subprocess
    raise InstallationError(exc_msg)
pipenv.patched.notpip._internal.exceptions.InstallationError: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

顺便说一句:我同时升级到Python 3.9.1。

您可能希望提供更多信息以使人们更容易回答您的问题,下面显示了一些示例和建议。

  1. 声明“这可能是由 google-ads 中的错误引起的。向其维护者报告此问题。”由 pipenv 提出。这意味着“请不要将问题报告给 pipenv 开发团队”。

  2. 不要急于声称您发现了错误:这是来自 "How To Ask Questions The Smart Way" by Eric Steven Raymond 的建议。您可以查看 link 以了解有关原因的更多详细信息。因此,我建议您先调查您的操作,而不是联系 Google 广告。

  3. 看来你是运行上了一个mac/OSX的命令。此外,您的 pipenv 似乎是由 brew 安装的。如果两种说法都是正确的,那么很可能您正在混合使用系统级 pip 和本地安装的 pipenv(通过 brew)。这是不熟悉 python 包管理工作原理的人经常犯的错误。

    1. 因此,找到解决方案的第一个建议是,尽可能详细地说明系统(mac/OSX)上的python包管理相关信息。例如python --versionwhich pythonwhich pipwhich pipenv的输出信息通常是help。

    2. 如果你想使用 brew 为你管理包,请确保你用于安装 pipenv 和你的目标包的每一步都不会混淆你的系统 python 环境和你的本地(由 brew 或 python 虚拟环境管理)试图找出问题并找到解决方案时。例如,确保您是从一个“干净”且刚刚重新生成的终端开始您的操作。如果你想使用 brew,请确保你通过 brew 控制一切。激活自定义的 python 虚拟环境(例如 conda 环境)然后使用 brew 将是一个坏主意。

    3. 我希望在提供更多信息之前,人们无法为您提供其他更实用的解决方案建议。祝你好运。

我花了一段时间才弄明白,但这似乎是 Python 3.9(或 3.9.1)下的 pipenvgoogle-ads 模块结合使用的问题.

我的解决方案:

  1. 降级到 Python 3.8.6(对于我这个菜鸟来说这是一场斗争,以防万一你对此感兴趣:
  2. 正在 pipenv 中升级 pip

我是这样做的:

pipenv shell
pip install --upgrade pip
exit

然后终于成功了:

% pipenv install google-ads
Installing google-ads...
Adding google-ads to Pipfile's [packages]...
✔ Installation Succeeded 
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Updated Pipfile.lock (aba984)!
Installing dependencies from Pipfile.lock (aba984)...
     ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

万岁!