python - 无法使用 pip 安装包 bpy

标签 python pip blender bpy

问题描述: 在 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' 遇到同样的错误

-------- 结论:--------

不能在 Blender 之外使用 bpy。我在 Blender Stack Exchange 上的另一篇文章中找到了一些解决方法(我还没有尝试过) 感谢 Anand 和 phd 提供的非常有用的链接!

最佳答案

据我所知,实际上可以在 blender 之外运行 bpy,并且声称其他情况下的信息是为旧版本编写的。我不得不承认,我仍在安装 bpy,这不是一件容易的事,我还不能验证这一 pip 。

在您的情况下,缺少 pip 模块。您可以使用 pip install future_fstrings 安装它。看看https://pypi.org/project/bpy/了解更多指南。

编辑:我能够在 Windows 和 Linux 下安装 bpy。它在 Linux 上抛出一些错误,但在 Windows 下工作正常。绝对独立工作!

关于python - 无法使用 pip 安装包 bpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63178840/

相关文章:

python - mujoco linux 包安装报错: exit status 1

django - 在分发包中使用 virtualenv 部署 Django?

c++ - 以编程方式生成可以导入 blender 的 3D 模型

python - GAE : Is it necessary to call fetch on a query before getting its cursor?

python - 在 Flask 模板中打印变量

python - 安装 pip 软件包或升级 pip 时出现环境错误 [Errno 2]

python - Blender Python 上的对象位置更改

python - 我对 Blender 中的 Python 脚本有一个严重的问题

python - 通过product services api获取亚马逊商品的红色标价

python - jinja2递归循环与字典