简体   繁体   English

无法从 linux-ubuntu 终端导入模块

[英]Cannot import module from linux-ubuntu terminal

I installed the keyboard module for python with pip3 and after I runned my code the terminal shows me this message: "ImportError: You must be root to use this library on linux."我用 pip3 为 python 安装了键盘模块,在我运行我的代码后,终端向我显示了这条消息: “ImportError:你必须是 root 才能在 linux 上使用这个库。” Can anybody help me how to run it well?有人可以帮我如何运行它吗? I tried to run it by switching to "su -" and tried it on this place as well.我试图通过切换到“su -”来运行它,并在这个地方也尝试过。

Can you please post your script?你能把你的脚本贴出来吗?

If you are just starting the program without a shebang it probably should not run and probably throw an ImportError如果你只是在没有 shebang 的情况下启动程序,它可能不应该运行并且可能抛出一个ImportError

Try adding a shebang ( #! ) at the first line of you script.尝试在脚本的第一行添加一个 shebang ( #! )。

A shebang is used in unix to select the interpreter you want to run your script.在 unix 中使用 shebang 来选择要运行脚本的解释器。

Write this in the first line: #!/usr/bin/env python3在第一行写: #!/usr/bin/env python3

If this doesn't help try running it from the terminal using a precending dot like this:如果这没有帮助,请尝试使用像这样的前置点从终端运行它:

python3 ./{file's_name}.py

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

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