mac 在终端上运行脚本,提示PermissionError: [Errno 1] Operation not permitted

本文介绍了解决Python脚本运行时出现权限不足错误的方法。通过使用sudo命令以超级用户权限运行ipython,成功解决了PermissionError问题,并展示了如何用python-ping库检查网络连通性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在终端上运行脚本时,提示权限不足PermissionError: [Errno 1] Operation not permitted

解决办法是给脚本个超级权限

173-16-0-191:~ wangying$ sudo ipython
Password:
Python 3.7.6 (v3.7.6:43364a7ae0, Dec 18 2019, 14:12:53) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from pythonping import ping                                             

In [2]: ping('192.169.0.1')                                                     
Out[2]: 
Reply from 192.169.0.1, 29 bytes in 2.52ms
Reply from 192.169.0.1, 29 bytes in 1.61ms
Reply from 192.169.0.1, 29 bytes in 1.44ms
Reply from 192.169.0.1, 29 bytes in 1.79ms

Round Trip Times min/avg/max is 1.44/1.84/2.52 ms

 

 

npm ERR! code EPERM npm npm ERR! syscall unlink npm ERR! path D: UmmppManagerFrontlnode modulesl. staging echarts - 619c8c12dist echarts . common . min.js npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, unlink D: mmppManagerFront node modulesl. staginglecharts -619c8c12distlecharts .common.min. js' npm ERR! [OperationalError: EPERM: operation not permitted, unlink 'D: mmppManagerFrontlnode_ modulesl. staginglecharts - 619c8c12distlecharts . common.min.js'] f npm ERR! cause: [Error: EPERM: operation not permitted, unlink D: mmppManagerFrontlnode_ modulesl. staginglecharts-619c8c12ldistlecharts . common .min.js' ] í nnm ERRI errno: -4048 npm errno:-404ö, npm ERR! code:' EPERM npm ERR! syscall: 'unlink', npm ERR! path: . D: VmmppManagerFrontIlnode modulesll. stagingllecharts - 619c8c1211distllecharts . common.min. js . npm ERR! npm ERR! errno: - 4048 , nom ERR! code: " EPERM npm ERR syscall: 'unlink' , npm ERR! path: 'D: VmmppManagerFrontnode modulesll. stagingllecharts - 619c8c121distllecharts . common.min.js', npm ERR! parent:' mmppManagerFront npm ERR! npm ERR! npm ERR! The operation was rejected by your operating system . npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR . ERR! or that you ou lack permissions to accesst. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/ Admini strator . npm ERR! A complete log of this run can be found in npmERR! c: Userslc-wangxs2VAppDatalRoamingnpm cachel logs 2025-04-02T05 28_ 49 264Z-debug. log
最新发布
04-03
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值