M1 Mac 上的 TensorFlow(任何版本 > 2.5.0):PyCharm 中没有代码补全
我正在使用 JetBrain 的 PyCharm IDE 在 M1 Mac 计算机上与 TensorFlow 配合使用。 我已按照给定顺序使用以下命令安装了 TensorFlow:
conda create -n data-science -y python=3.9
conda activate data-science
conda install -c apple tensorflow-deps
pip install tensorflow-macos
pip install tensorflow-metal
对于安装 Conda,我遵循 Apple 官方 文档
我可以毫无问题地导入 TensorFlow;它打印的版本号是2.8.0
。 但是,我没有收到任何代码完成建议。 输入tensorflow.keras.l
时,它应该建议layers
或losses
。 正如所附的屏幕截图所示,我没有得到任何可用的东西:
我已经重新启动了IDE,使所有缓存失效,重新索引项目,并从头开始重新创建环境多次,但都无济于事。其他建议按预期工作(例如屏幕截图中的 os.path.join 行)。让我困惑的是,在同一台机器(M1 Mac)上的另一个项目中,我使用 TensorFlow 2.5.0
,它为我提供了所需的代码建议。
由于无法获取最新 TensorFlow 版本的代码建议,我无法更新到版本 2.8.0
。您对解决这个问题有什么建议?
I am using JetBrain's PyCharm IDE to work with TensorFlow on a M1 Mac machine.
I have installed TensorFlow using the following commands in the given order:
conda create -n data-science -y python=3.9
conda activate data-science
conda install -c apple tensorflow-deps
pip install tensorflow-macos
pip install tensorflow-metal
For installing Conda, I followed Apple's official documentation
I can import TensorFlow without problems; the version number it prints is 2.8.0
.
However, I am not getting any code completion suggestions.
When typing tensorflow.keras.l
, it should suggest layers
, or losses
.
As the attached screenshot shows, I am not getting anything usable:
I have restarted the IDE, invalidated any caches, re-indexed the project, and re-created the environment from scratch multiple times, all to no avail. Other suggestions are working as expected (such as the os.path.join
line in the screenshot). What puzzles me is that, in another project on the very same machine (M1 Mac), I am using TensorFlow 2.5.0
, which gives me the desired code suggestions.
The inability to get code suggestion for more recent TensorFlow versions has stopped me from updating to, e.g., version 2.8.0
. What are your suggestions to solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于代码补全,您可以按照以下解决方法进行操作。
有关更多详细信息,请参阅此处 。
For code completion you can follow below workaround
For more details please refer here.