python模块nmap无法安装

时间:2019-07-06 17:55:07

标签: python-3.x visual-studio visual-studio-2017 nmap

这里是python新手。我正在尝试使用python nmap库。为了进行安装,我还使用以下失败的命令,并显示以下错误。

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64>pip install python-nmap
Collecting python-nmap
  Using cached https://files.pythonhosted.org/packages/dc/f2/9e1a2953d4d824e183ac033e3d223055e40e695fa6db2cb3e94a864eaa84/python-nmap-0.6.1.tar.gz
Installing collected packages: python-nmap
  Running setup.py install for python-nmap ... error
    Complete output from command "c:\program files (x86)\microsoft visual studio\shared\python36_64\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\root\\AppData\\Local\\Temp\\pip-install-lsrfn3ac\\python-nmap\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\root\AppData\Local\Temp\pip-record-t73k4f0r\install-record.txt --single-version-externally-managed --compile:
    c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build\lib
    creating build\lib\nmap
    copying nmap\nmap.py -> build\lib\nmap
    copying nmap\test.py -> build\lib\nmap
    copying nmap\test_nmap.py -> build\lib\nmap
    copying nmap\__init__.py -> build\lib\nmap
    running install_lib
    creating c:\program files (x86)\microsoft visual studio\shared\python36_64\Lib\site-packages\nmap
    error: could not create 'c:\program files (x86)\microsoft visual studio\shared\python36_64\Lib\site-packages\nmap': Access is denied

    ----------------------------------------
Command ""c:\program files (x86)\microsoft visual studio\shared\python36_64\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\root\\AppData\\Local\\Temp\\pip-install-lsrfn3ac\\python-nmap\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\root\AppData\Local\Temp\pip-record-t73k4f0r\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\root\AppData\Local\Temp\pip-install-lsrfn3ac\python-nmap\

有什么想法我在这里做错了吗?

1 个答案:

答案 0 :(得分:1)

错误:无法创建'c:\ program files(x86)\ microsoft visual studio \ shared \ python36_64 \ Lib \ site-packages \ nmap':访问被拒绝

这表示未创建新文件,因此显然具有所有者权限。只需以管理员或root 身份运行终端,并验证在终端中键入python时加载哪个版本的python解释器,否则使用pip3而不是pip,因为这会获得python3软件包。