问题描述:在 VS Code 中,运行命令pip install bpy(如https://pypi.org/project/bpy/所示)并得到以下错误消息:
PS C:\Users\(...)\Local\Programs\Python\Python38> pip install bpy
Collecting bpy
Using cached bpy-0.0.0a0.tar.gz (19 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\users\(...)\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\(...)\\Local\\Temp\\pip-install-xln6pb4c\\bpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\(...)\\Local\\Temp\\pip-install-xln6pb4c\\bpy\\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 'C:\Users\(...)\Local\Temp\pip-pip-egg-info-0pdk7e9q'
cwd: C:\Users\(...)\Local\Temp\pip-install-xln6pb4c\bpy\
Complete output (16 lines):
Traceback (most recent call last):
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 342, in find_cookie
codec = lookup(encoding)
LookupError: unknown encoding: future_fstrings
During handling of the above exception, another exception occurred:
File "<string>", line 1, in <module>
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 394, in open
encoding, lines = detect_encoding(buffer.readline)
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 381, in detect_encoding
encoding = find_cookie(second)
File "c:\users\(...)\local\programs\python\python38\lib\tokenize.py", line 350, in find_cookie
raise SyntaxError(msg)
SyntaxError: unknown encoding for 'C:\\Users\\(...)\\Local\\Temp\\pip-install-xln6pb4c\\bpy\\setup.py': future_fstrings
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. code here
-------我尝试过的(没有成功):-------
安装轮子(pip install wheel),然后从pypi.org下载包手动安装: pip install 'C:\Users(...)\Downloads\bpy-2.82.1.tar.gz' got the same error。
--------结论:--------
不能在 Blender 之外使用 bpy。我在Blender Stack Exchange上的另一篇文章中找到了一些解决方法(我还没有尝试过) 感谢 Anand 和 phd 提供了非常有用的链接!