You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python2虚拟环境部署Impacket遇dsinternals版本兼容错误求助

问题:Python2虚拟环境部署Impacket时遭遇dsinternals兼容错误

操作流程

我尝试在Python2虚拟环境中部署Impacket,执行了以下步骤:

cd /opt
sudo git clone https://github.com/SecureAuthCorp/impacket.git
sudo chmod 777 /opt/impacket -R
sudo apt install virtualenv
cd /opt/impacket
sudo virtualenv impacket-venv -p $(which python2)
source impacket-venv/bin/activate
cd /tmp                                                                                                                                                
wget  https://bootstrap.pypa.io/pip/2.7/get-pip.py -O /tmp/get-pip.py --no-check-certificate
sudo python2 get-pip.py

cd /opt/impacket
pip install -r requirements.txt

执行错误输出

运行后得到如下错误:

ng cached ldap3-2.9.1-py2.py3-none-any.whl (432 kB)
Collecting ldapdomaindump>=0.9.0
  Using cached ldapdomaindump-0.9.4-py2-none-any.whl (18 kB)
Collecting flask>=1.0
  Using cached Flask-1.1.4-py2.py3-none-any.whl (94 kB)
Collecting dsinternals
  Using cached dsinternals-1.2.4.tar.gz (174 kB)
ERROR: Package 'dsinternals' requires a different Python: 2.7.18 not in '>=3.4'

已尝试的无效操作

我试过执行以下命令:

pip install --no-cache-dir --upgrade 'dsinternals<3.4'

但仍然报错:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.                             
Collecting dsinternals<3.4
  Downloading dsinternals-1.2.4.tar.gz (174 kB)
     |████████████████████████████████| 174 kB 1.2 MB/s 
ERROR: Package 'dsinternals' requires a different Python: 2.7.18 not in '>=3.4'

解决方案

原因说明

dsinternals从1.0版本开始就仅支持Python3.4及以上版本,无任何兼容Python2的发行版。而当前克隆的Impacket新版本已经引入了dsinternals作为依赖,导致Python2环境无法满足要求。

解决步骤

  1. 切换到Impacket最后支持Python2的稳定版本(以impacket-0.9.24为例,该版本无dsinternals依赖):
cd /opt/impacket
git checkout tags/impacket-0.9.24
  1. 重新执行虚拟环境激活和依赖安装步骤:
source impacket-venv/bin/activate
pip install -r requirements.txt

备选方案(不推荐)

如果必须使用最新版Impacket,可手动修改requirements.txt文件,移除dsinternals相关依赖项,但这会导致Impacket中依赖该库的功能无法正常使用。

内容的提问来源于stack exchange,提问作者catchabyte

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 14:52:34