Search code examples
python-3.xvisual-studiovisual-studio-2017nmap

python module nmap could not be installed


A python novice here. I am trying to use python nmap library. In order to install that I use following command that is failing with error shown below as well.

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\

Any ideas what I am doing wrong here?


Solution

  • error: could not create 'c:\program files (x86)\microsoft visual studio\shared\python36_64\Lib\site-packages\nmap': Access is denied

    This says a new file is not being created so its clearly a owner permissions.just run the terminal as administrator or root and also verify which version of python interpreter loads when typing python in terminal else just use the pip3 instead of pip as this gets the python3 package.