为了账号安全,请及时绑定邮箱和手机立即绑定

Python 权限问题 Ubuntu

Python 权限问题 Ubuntu

繁华开满天机 2021-09-11 14:58:19
我正在尝试运行一个简单的 python 脚本$python Solution.py read_input.txt只有当我使用 sudo 时,$sudo python Solution.py read_input.txt我收到以下错误消息:Traceback (most recent call last):  File "Solution1.py", line 2, in <module>   import numpy as npImportError: No module named numpy这是由于权限问题。$which python/home/andrelandgraf/anaconda3/bin/python$sudo which python/usr/bin/python我想使用我的 anaconda env 来运行该文件,但由于权限原因,我无法在没有 sudo 的情况下运行 python,这将导致运行无法访问 numpy.python 的系统版本。我试过 chmod 和 chown 给 python 所需的权限$chmod -R 777 .但是每当我在没有 sudo 的情况下运行 python 时,它只会打印一个空行,什么也没有发生。我还检查了我的 .bashrc 文件并回显了 $PATH,anaconda3 似乎安装得很好。$PATH: /home/andrelandgraf/anaconda3/bin:/home/andrelandgraf/bin:/home/andrelandgraf/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin我该如何解决这个问题?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 221 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信