简体   繁体   English

从命令行运行 python 要求我导入模块

[英]Running python from command line asks me to import modules

I have a script written in Spyder(Python 3.8) on Linux.我在 Linux 上有一个用 Spyder(Python 3.8)编写的脚本。 While on the Spyder console the script runs fine, while I an calling it from the Linux terminal it seems like it doesn't see the modules I import in the script.在 Spyder 控制台上,脚本运行良好,而我从 Linux 终端调用它时,它似乎看不到我在脚本中导入的模块。 Opening the terminal I run: python3 /zhome/c9/f/144817/Desktop/ChargersDaniel.py but, here is the error I take:打开我运行的终端: python3 /zhome/c9/f/144817/Desktop/ChargersDaniel.py但是,这是我遇到的错误:

Traceback (most recent call last):  File "/zhome/c9/f/144817/Desktop/ChargersDaniel.py", line 9, in <module>
import GPyOpt ModuleNotFoundError: No module named 'GPyOpt'

where GPyOpt is the very first library I have at the first lines in my script.其中 GPyOpt 是我在脚本第一行中拥有的第一个库。 It looks like for some reason, python3 doesn't see the libraries installed.看起来由于某种原因,python3 没有看到安装的库。 I have checked the solution here but that's not my case cause I am already calling Python3 at my terminal.我已经在这里检查了解决方案,但这不是我的情况,因为我已经在终端调用 Python3。

Any suggestions?有什么建议么? Thanks in advance提前致谢

Maybe check if GPyOpt is installed when running from your terminal:从终端运行时检查是否安装了 GPyOpt:

python3 -c "import GPyOpt"
if [ $? -eq 0 ]
then
  echo "GPyOpt is installed!"
fi  

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

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