简体   繁体   English

没有名为“bpy”的模块,但已安装

[英]No module named 'bpy' but it's installed

I've been trying to install bpy for a few hours.我已经尝试安装 bpy 几个小时了。 I used 'pip install bpy', and got some errors about the 'bpy_types' module.我使用了“pip install bpy”,但遇到了一些关于“bpy_types”模块的错误。 I followed this thread and found the bpy_post_install executable.我关注了这个线程并找到了 bpy_post_install 可执行文件。 I also tried the steps involving the 2.82 folder from \Scripts.我还尝试了涉及 \Scripts 中的 2.82 文件夹的步骤。 After I ran bpy_post_install, python is unable to find bpy whatsoever when I run through VSCode.在我运行 bpy_post_install 之后,当我运行 VSCode 时,python 无论如何都找不到 bpy。 I run python3 __init__.py and get error line 4, in <module> import bpy ModuleNotFoundError: No module named 'bpy' .我运行python3 __init__.pyline 4, in <module> import bpy ModuleNotFoundError: No module named 'bpy' I then attempt pip install bpy and get Requirement already satisfied: bpy in C:\users\... (2.82) .然后我尝试pip install bpy并获得Requirement already satisfied: bpy in C:\users\... (2.82)

I'm pretty much at a loss, I've never seen python claim a module wasn't installed when it clearly is.我几乎不知所措,我从来没有见过 python 声称一个模块没有安装,而它显然是。

I see that you're having an issue with bpy seeming not to be "installed" (I put that in air quotes since you obviously installed it with the terminal.)我看到您遇到了 bpy 似乎没有被“安装”的问题(我把它放在引号中,因为您显然是用终端安装的。)

Firstly I watched this video - Blender Addon #1 - Python Programming Introduction (Bpy module, data, Context and Types) Which gave me some useful insight into both the bpy module and how you can use it.首先,我观看了这个视频 - Blender Addon #1 - Python Programming Introduction(Bpy 模块、数据、上下文和类型),它让我对 bpy 模块以及如何使用它有了一些有用的见解。

In the video he breaks down some of these things so you don't have to watch an 18 minute video.在视频中,他分解了其中一些内容,因此您不必观看 18 分钟的视频。

Prerequisites?先决条件?

  • Basic Knowledge of OOP, Python, and Blender (Object Orientated Programming = OOP) OOP、Python 和 Blender 的基础知识(面向对象编程 = OOP)

His tutorial Scripting Tab under the application name, window, and exit buttons very far right.他的教程Scripting Tab 下的应用程序名称、窗口和退出按钮非常靠右。

It opens something called a REPL window它打开一个叫做 REPL 窗口的东西

  • Read
  • Evaluate评估
  • Print打印
  • Loop环形

When I tried this it worked, and also did not work which is seemly weird当我尝试这个时,它起作用了,也没有起作用,这似乎很奇怪

  • When I opened one of my complex modules that I was going to use for Three.Js it worked flawlessly - type bpy and then hit tab it should show up with all of the prefill answers当我打开我打算用于Three.Js的一个复杂模块时,它完美地工作 -输入 bpy 然后点击选项卡,它应该会显示所有预填答案

  • However, when I used a new blender file with the cube it started giving me errors.但是,当我对立方体使用新的搅拌机文件时,它开始给我错误。


Now about the error you are facing here is what I found现在关于您在这里面临的错误是我发现的

Blender Stack exchange搅拌机堆栈交换

  • People have said that bpy is only available inside of blender from the Python Interpreter itself.人们说 bpy 只能在 Python 解释器本身的 blender 内部使用。 However, this is old and from 2013. Here is the thread但是,这是旧的,从 2013 年开始。 这是线程

Github Github

  • There was a thread (which is linked) that had more or less the same issue.有一个线程(已链接)或多或少有相同的问题。
    • CarlosDubarreto on Apr 26 said that you could use conda to install the bpy module CarlosDubarreto 在 4 月 26 日说你可以使用conda安装 bpy 模块
    • However, he states that it may only work if you are using at least miniconda.但是,他说它可能仅在您至少使用 miniconda 时才有效。 Referenced Used参考使用

What is conda?什么是康达?

  • Conda is an open source, cross-platform, language-agnostic package manager and environment management system Conda Documentation Conda 是一个开源、跨平台、与语言无关的包管理器和环境管理系统Conda 文档

Difference between conda and pip conda 和 pip 的区别

  • Is what they put packages in. Pip packages are Python libraries like NumPy or Matplotlib.是他们放入包的东西。Pip 包是 Python 库,如 NumPy 或 Matplotlib。 However, conda packages include Python Libraries, C Libraries, and executables like C compilers, and even the Python interpreter itself.但是,conda 包包括 Python 库、C 库和 C 编译器等可执行文件,甚至 Python 解释器本身。

To get bpy to work with the Conda Method mentioned above.让 bpy 使用上面提到的 Conda 方法。

After installing Conda run this line of code mentioned in the GitHub method above安装 Conda 后运行上面 GitHub 方法中提到的这行代码

conda install -c kitsune.one python-blender

Alternative Method替代方法

  • Within the GitHub thread xiezhongzhao said you could install fake-bpy.在 GitHub 线程中 xiezhongzhao 说你可以安装 fake-bpy。 Link to fake-bpy链接到 fake-bpy

  • The line he mentions to run is:他提到要运行的线路是:

    pip install fake-bpy-module-2.80 pip install fake-bpy-module-2.80

However I recommend running this line instead, and it's mentioned in the GitHub repo above但是我建议改为运行这一行,它在上面的 GitHub 存储库中提到

pip install fake-bpy-module-latest

I recommend this since it will be the latest version not a specific blender version我推荐这个,因为它将是最新版本而不是特定的搅拌机版本

However, people within that GitHub thread have said they are still getting errors related to bpy within Python so try it and let me know.但是,该 GitHub 线程中的人表示,他们仍然在 Python 中遇到与 bpy 相关的错误,因此请尝试并告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导入错误:没有名为“bpy”的模块 - ImportError: No module named 'bpy' ModuleNotFoundError:没有名为“PyDIP”的模块,尽管它已安装 - ModuleNotFoundError: No module named 'PyDIP', although it's installed 没有名为“ scipy.stats”的模块,但已安装 - No module named 'scipy.stats', but it's installed 没有名为 jinja2 的模块,但它已安装 - No module named jinja2, yet it's installed 没有名为 django 的模块,但已安装 - No module named django but it is installed python错误即使安装了没有名为pygame的模块 - Python error no module named pygame eventhough it's installed “ ImportError:没有名为google.protobuf的模块”,但绝对可以安装 - “ImportError: No module named google.protobuf” but it's definitely installed python没有名为ujson的模块,虽然已经安装了 - python No module named ujson, while it's already installed PyCharm中没有名为“ Keras”的模块,尽管它已安装并且在终端中可以正常工作 - No module named 'Keras' in PyCharm, although it's installed and works fine in the terminal 运行 python 可执行文件时没有名为“请求”的模块,即使它已安装 - No module named 'requests' when running python executable, even it's installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM