python3.6 安装protobuf_to_dict报错问题解决

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

安装:pip3 install protobuf-to-dict==0.0.5

安装后找到安装路径,修改文件python3.6/site-packages/protobuf_to_dict.py

把long改成int

unicode改成str

encode编码删除

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

Collecting package metadata (current_repodata.json): failed # >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<< Traceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 60, in __call__ return cls._thread_local.session AttributeError: &#39;_thread._local&#39; object has no attribute &#39;session&#39; During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/conda/exceptions.py", line 1079, in __call__ return func(*args, **kwargs) File "/opt/conda/lib/python3.6/site-packages/conda/cli/main.py", line 84, in _main exit_code = do_call(args, p) File "/opt/conda/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 83, in do_call return getattr(module, func_name)(args, parser) File "/opt/conda/lib/python3.6/site-packages/conda/cli/main_install.py", line 20, in execute install(args, parser, &#39;install&#39;) File "/opt/conda/lib/python3.6/site-packages/conda/cli/install.py", line 265, in install should_retry_solve=(_should_retry_unfrozen or repodata_fn != repodata_fns[-1]), File "/opt/conda/lib/python3.6/site-packages/conda/core/solve.py", line 117, in solve_for_transaction should_retry_solve) File "/opt/conda/lib/python3.6/site-packages/conda/core/solve.py", line 158, in solve_for_diff force_remove, should_retry_solve) File "/opt/conda/lib/python3.6/site-packages/conda/core/solve.py", line 262, in solve_final_state ssc = self._collect_all_metadata(ssc) File "/opt/conda/lib/python3.6/site-packages/conda/common/io.py", line 88, in decorated return f(*args, **kwds) File "/opt/conda/lib/python3.6/site-packages/conda/core/solve.py", line 425, in _collect_all_metadata index, r = self._prepare(prepared_specs) File "/opt/conda/lib/python3.6/site-packages/conda/core/solve.py", line 1021, in _prepare self.subdirs, prepared_specs, self._repodata_fn) File "/opt/conda/lib/python3.6/site-packages/conda/core/index.py", line 289, in get_reduced_index repodata_fn=repodata_fn) File "/opt/conda/lib/python3.6/site-packages/conda/core/subdir_data.py", line 140, in query_all result = tuple(concat(executor.map(subdir_query, channel_urls))) File "/opt/conda/lib/python3.6/concurrent/futures/_base.py", line 586, in result_iterator yield fs.pop().result() File "/opt/conda/lib/python3.6/concurrent/futures/_base.py", line 432, in result return self.__get_result() File "/opt/conda/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/opt/conda/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/opt/conda/lib/python3.6/site-packages/conda/core/subdir_data.py", line 133, in <lambda> package_ref_or_match_spec)) File "/opt/conda/lib/python3.6/site-packages/conda/core/subdir_data.py", line 145, in query self.load() File "/opt/conda/lib/python3.6/site-packages/conda/core/subdir_data.py", line 209, in load _internal_state = self._load() File "/opt/conda/lib/python3.6/site-packages/conda/core/subdir_data.py", line 375, in _load repodata_fn=self.repodata_fn) File "/opt/conda/lib/python3.6/site-packages/conda/core/subdir_data.py", line 680, in fetch_repodata_remote_request session = CondaSession() File "/opt/conda/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 62, in __call__ session = cls._thread_local.session = super(CondaSessionType, cls).__call__() File "/opt/conda/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 88, in __init__ raise_on_status=False) TypeError: __init__() got an unexpected keyword argument &#39;raise_on_status&#39; `$ /opt/conda/bin/conda install -c conda-forge dlib -y` environment variables: CIO_TEST=<not set> CONDA_ROOT=/opt/conda CURL_CA_BUNDLE=<not set> GRADIO_ROOT_PATH=/bj-cpu-01/user/16875729/9912179/api_serving/7860 IDE_HUB_PROXY_1_SERVICE_PORT_PROXY=<set> LD_LIBRARY_PATH=/usr/local/cuda-11.2/targets/x86_64-linux/lib/:/usr/local/cuda-11.2/li b64:/usr/local/cuda-11.2/targets/x86_64-linux/:/usr/lib/x86_64-linux-g nu:/usr/local/cuda/lib64:/opt/conda/envs/python35-paddle120-env/lib:/u sr/lib64:/usr/local/lib:/usr/local/cuda-12.6/lib64 LIBRARY_PATH=/usr/local/cuda/lib64/stubs PATH=/home/aistudio/.data/webide/pip/bin:/opt/conda/envs/python35-paddle120 -env/bin:/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr /local/sbin:/usr/sbin:/sbin:/home/work/bin:/home/work/.local/bin:/usr/ local/bin:/usr/bin:/bin PYTHONUSERBASE=/home/aistudio/.data/webide/pip REQUESTS_CA_BUNDLE=<not set> SSL_CERT_FILE=<not set> WEBIDE_SYS_PYTHON_PATH=/opt/conda/envs/webide/bin WEBIDE_USER_PYTHON_PATH=/opt/conda/envs/python35-paddle120-env/bin active environment : None user config file : /home/aistudio/.condarc populated config files : /home/aistudio/.condarc conda version : 4.10.1 conda-build version : not installed python version : 3.6.8.final.0 virtual packages : __cuda=12.0=0 __linux=5.4.0=0 __glibc=2.23=0 __unix=0=0 __archspec=1=x86_64 base environment : /opt/conda (writable) conda av data dir : /opt/conda/etc/conda conda av metadata url : https://repo.anaconda.com/pkgs/main channel URLs : https://conda.anaconda.org/conda-forge/linux-64 https://conda.anaconda.org/conda-forge/noarch https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /opt/conda/pkgs /home/aistudio/.conda/pkgs envs directories : /opt/conda/envs /home/aistudio/.conda/envs platform : linux-64 user-agent : conda/4.10.1 requests/2.22.0 CPython/3.6.8 Linux/5.4.0-139-generic ubuntu/16.04.6 glibc/2.23 UID:GID : 1000:1000 netrc file : None offline mode : False An unexpected error has occurred. Conda has prepared the above report. Upload did not complete. Looking in indexes: https://mirror.baidu.com/pypi/simple/, https://mirrors.aliyun.com/pypi/simple/ Requirement already satisfied: opencv-python in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (4.1.1.26) Requirement already satisfied: numpy in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (1.20.3) Requirement already satisfied: pandas in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (1.1.5) Requirement already satisfied: matplotlib in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (2.2.3) Requirement already satisfied: scikit-learn in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (0.24.2) Collecting paddlepaddle-gpu==1.8.5.post107 Using cached https://mirrors.aliyun.com/pypi/packages/55/dc/0d66f7c06cb3efea5caef4e82ebf2dd245ffcda635b2e5ca15ef0fc2a2e7/paddlepaddle_gpu-1.8.5.post107-cp37-cp37m-manylinux1_x86_64.whl (407.2 MB) Requirement already satisfied: protobuf>=3.1.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (3.20.1) Requirement already satisfied: six in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (1.16.0) Requirement already satisfied: scipy in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (1.6.3) Requirement already satisfied: rarfile in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (3.1) Requirement already satisfied: gast==0.3.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (0.3.3) Requirement already satisfied: decorator in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (4.4.2) Requirement already satisfied: requests>=2.20.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (2.22.0) Requirement already satisfied: graphviz in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (0.13) Requirement already satisfied: pyyaml in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (5.1.2) Requirement already satisfied: pathlib in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (1.0.1) Requirement already satisfied: funcsigs in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (1.0.2) Requirement already satisfied: Pillow in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (8.2.0) Requirement already satisfied: astor in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (0.8.1) Requirement already satisfied: objgraph in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (3.4.1) Requirement already satisfied: nltk in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (3.4.5) Requirement already satisfied: prettytable in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from paddlepaddle-gpu==1.8.5.post107) (0.7.2) Requirement already satisfied: pytz>=2017.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from pandas) (2019.3) Requirement already satisfied: python-dateutil>=2.7.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from pandas) (2.8.2) Requirement already satisfied: cycler>=0.10 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (0.10.0) Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (1.1.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib) (3.0.9) Requirement already satisfied: threadpoolctl>=2.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn) (2.1.0) Requirement already satisfied: joblib>=0.11 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn) (0.14.1) Requirement already satisfied: setuptools in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib) (56.2.0) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.20.0->paddlepaddle-gpu==1.8.5.post107) (1.25.6) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.20.0->paddlepaddle-gpu==1.8.5.post107) (3.0.4) Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.20.0->paddlepaddle-gpu==1.8.5.post107) (2019.9.11) Requirement already satisfied: idna<2.9,>=2.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests>=2.20.0->paddlepaddle-gpu==1.8.5.post107) (2.8) Installing collected packages: paddlepaddle-gpu Attempting uninstall: paddlepaddle-gpu Found existing installation: paddlepaddle-gpu 2.2.2.post101 Uninstalling paddlepaddle-gpu-2.2.2.post101: Successfully uninstalled paddlepaddle-gpu-2.2.2.post101 Successfully installed paddlepaddle-gpu-1.8.5.post107 [notice] A new release of pip available: 22.1.2 -> 24.0 [notice] To update, run: pip install --upgrade pip
最新发布
01-01
运行代码时报错:import os import torch from modelscope.pipelines import pipeline from modelscope.utils.constant import Tasks from pydub import AudioSegment def load_asr_model(model_path=“D:/models/iic/speech_paraformer-large-vad-punc-spk_asr_nat-zh-cn”, device=None): “”" 加载ASR模型 - 修复版本 参数: model_path: 本地模型路径 device: 指定设备 (None=自动选择) 返回: 初始化的ASR管道 “”" if device is None: device = ‘cuda’ if torch.cuda.is_available() else ‘cpu’ print(f"🔄 正在加载模型: {model_path} (设备: {device})...") return pipeline( task=Tasks.auto_speech_recognition, model=model_path, device=device, model_revision=&#39;v2.0.4&#39; # 指定模型版本确保兼容性 ) def convert_to_wav(input_path, output_dir=“wav_output”, sample_rate=16000, channels=1): “”“将任意音频格式转换为标准WAV格式”“” os.makedirs(output_dir, exist_ok=True) filename = os.path.basename(input_path) name, _ = os.path.splitext(filename) output_path = os.path.join(output_dir, f"{name}.wav") try: audio = AudioSegment.from_file(input_path) audio = audio.set_frame_rate(sample_rate) audio = audio.set_channels(channels) audio.export(output_path, format="wav") print(f"✅ 转换完成: {input_path} -> {output_path}") return output_path except Exception as e: print(f"❌ 转换失败: {e}") return None def run_asr(asr_pipeline, wav_path): “”" 执行语音识别 - 修复版本 参数: asr_pipeline: 加载的模型管道 wav_path: WAV文件路径 返回: 识别结果字典 “”" print(f"🔊 开始识别: {wav_path}") # 修复:处理长音频的VAD配置 param_dict = { "vad_model": "fsmn-vad", # 显式指定VAD模型 "punc_model": "ct-punc", # 显式指定标点模型 "max_length_s": 60, # 最大处理长度(秒) "batch_size_token": 5, # 批处理大小 } result = asr_pipeline(audio_in=wav_path, param_dict=param_dict) # 解析结果 print("\n📝 识别结果:") if "text" in result: print(f"完整文本: {result[&#39;text&#39;]}") if "sentences" in result: print("\n分段结果:") for i, sent in enumerate(result["sentences"]): print(f"{i+1}. {sent[&#39;text&#39;]} (时间: {sent[&#39;start&#39;]:.2f}s-{sent[&#39;end&#39;]:.2f}s)") if "speaker" in result: print("\n👥 说话人分离结果:") for spk in result["speaker"]: print(f" 说话人{spk[&#39;spk_id&#39;]}: {spk[&#39;text&#39;]} (时间: {spk[&#39;start&#39;]:.2f}s-{spk[&#39;end&#39;]:.2f}s)") return result if name == “main”: # 配置参数 MODEL_PATH = “D:/models/iic/speech_paraformer-large-vad-punc-spk_asr_nat-zh-cn” INPUT_AUDIO = “test_audio.mp3” # 支持MP3, WAV, FLAC等格式 # 1. 音频转换 wav_file = convert_to_wav( input_path=INPUT_AUDIO, sample_rate=16000, channels=1 ) if not wav_file: exit(1) # 2. 模型加载 asr_pipeline = load_asr_model(MODEL_PATH) # 3. 执行识别 result = run_asr(asr_pipeline, wav_file) # 4. 保存结果 result_file = f"{os.path.splitext(wav_file)[0]}_result.txt" with open(result_file, "w", encoding="utf-8") as f: f.write(result["text"]) print(f"💾 结果已保存至: {result_file}") 报错信息:RuntimeError: Failed to import transformers.modeling_utils because of the following error (look up to see its traceback): Descriptors cannot be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0. If you cannot immediately regenerate your protos, some other possible workarounds are: Downgrade the protobuf package to 3.20.x or lower. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower). More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
08-05
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值