所以我安装了twitter easy_install twitter
my_file.py
.container-fluid
当我直接在终端上运行我的python文件时,它工作正常
a
但是,当我将上述内容放入shell文件
时run_script.sh
import twitter
......
......
我使用
运行此文件>python my_file.py
我收到错误
python my_file.py
为什么在通过shell脚本尝试导入的模块安装时无法识别?
答案 0 :(得分:1)
你需要在文件顶部给出一个sha - b,如 -
#!/usr/bin/env python
import twitter
Your code goes here ...
然后在终端运行此命令以使该文件可执行
$ chmod +x my_file.py
并在bash脚本中添加: -
./my_file.py
另外,请确保您已全局安装模块,而不是将其安装在virtualenv
中