简体   繁体   English

如何在VS Code和Ubuntu中使用Keras模块运行python代码?

[英]How can I run a python code with Keras module in VS Code and Ubuntu?

The OS is Ubuntu16.04. 操作系统是Ubuntu16.04。 I have installed python extension for VS Code. 我已经为VS Code安装了python扩展。 I can run a Hello World program in VS Code. 我可以在VS Code中运行Hello World程序。 But when there is import keras in the code, I encounter an error: [Running] python "/home/lym/Documents/py/test.py" Traceback (most recent call last): File "/home/lym/Documents/py/test.py", line 8, in <module> import keras ImportError: No module named keras 但是,当代码中有import keras时,我会遇到一个错误: [Running] python "/home/lym/Documents/py/test.py" Traceback (most recent call last): File "/home/lym/Documents/py/test.py", line 8, in <module> import keras ImportError: No module named keras

The code is here . 代码在这里 I can run this code in terminal. 我可以在终端中运行此代码。 But it seems that VS Code don't recognize the Keras module. 但是似乎VS Code无法识别Keras模块。

Thanks! 谢谢!

most likely you are using different python versions in VS code and terminal: 最有可能在VS代码和终端中使用不同的python版本:

check your python path in VS code: 在VS代码中检查您的python路径:

import sys
print(sys.path)

and compare it to the result of this code in your terminal: 并将其与您的终端中此代码的结果进行比较:

which python

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM