问题描述:
(树莓派)尝试用python输出pcapng文件中的内容,使用pip 无法安装pyshark、读取pcapng无权限。
ModuleNotFoundError: No module named 'pyshark'
This environment is externally managed
> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
使用的python代码如下
#hi.py
import pyshark
cap = pyshark.FileCapture('1.pcapng')
for packet in cap:
print(packet)
解决方法:
'''使用python虚拟环境安装pyshark、tshark(pyshark依赖)'''
python3 -m venv myenv
source myenv/bin/activate
sudo apt-get update
sudo apt-get install tshark
pip3 install pyshark
'''更改1.pcapng文件权限'''
sudo chown pi:pi /home/pi/bluetool/1.pcapng
'''运行输出pcapng代码'''
python3 hi.py
成功截图: