原代码 ↓
from openai import openAI
报错1:ModuleNotFoundError: No module named 'openai'
先前已经pip install openai了,还是找不到模块。上网搜了一下原因,发现是模块安装目录与当前python目录不一致
查看模块安排目录:pip show openai
Location: d:\program_files\anaconda3\lib\site-packages
查看当前python路径
> python
>>>import sys
>>>sys.executable
'D:\\Program_Files\\Anaconda3\\envs\\if\\python.exe'
此时要去环境变量里更改python路径优先级,我偷懒,直接进if环境重新pip(真·偷懒做法,慎用!)
报错1解决了,出现新问题
报错2:ImportError: cannot import name 'openAI' from 'openai' (D:\Program_Files\Anaconda3\envs\if\lib\site-packages\openai\__init__.py)
找资料发现是python啥的版本不合要求,往上翻安装openai时的记录,果然有一堆红字被我忽略了,看到succesful就自动忽略前面内容,大意了大意了
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.10.0 requires libclang>=13.0.0, which is not installed.
tensorflow 2.10.0 requires tensorflow-io-gcs-filesystem>=0.23.1, which is not installed.
tensorflow 2.10.0 requires protobuf<3.20,>=3.9.2, but you have protobuf 3.20.3 which is incompatible.
尝试1:按error里需要安装的装
pip install libclang>=13.0.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.10.0 requires tensorflow-io-gcs-filesystem>=0.23.1, which is not installed.
tensorflow 2.10.0 requires protobuf<3.20,>=3.9.2, but you have protobuf 3.20.3 which is incompatible.
好复杂的样子,放弃
尝试2:按网上搜到的版本配置新虚拟环境
create -n test python=3.8
python -m pip install --upgrade pip==24.0
pip install urllib3==1.25.11
pip install openai==1.7.0
这回没红字,仍然显示报错2
解决
在尝试2的基础上,发现问题所在,是我的OpenAI的o没有大写!!!啊啊啊啊啊啊费老大劲了结果错在这!!!!(尖叫)