Trying to install Shodan however access is denied

I am trying to install Shodan and I keep getting this access denied message.

I am stuck. I know that I have python installed.

Could be that your pip isn’t on your path correctly. Try calling through python module command, e.g.:

python -m pip install -U --user shodan

Pip generally tries to install things in a way that is not user-specific. If you are using Python that you installed directly, “for all users”, then Pip will also try to install “for all users” - to a place that is inside Program Files. To do this, Pip has to run as an admin user - just like the Python installer had to run as an admin user in order to install Python for all users.

Usually you should not really do this. In fact, it’s common to create “virtual environments” that are basically separate, isolated copies of Python that have their own separate set of installed libraries. This way, if anything goes really wrong, in the worst case you can just throw away that environment and start over.

If you really want to install it permanently, for everyone who uses the computer, it should only require getting elevated rights (UAC) first.

If you don’t want to use virtual environments, but only want this library for yourself, you can do a user-level installation. Pip will put it in a user-specific folder, and Python is already configured to look there automatically (in addition to the system library paths). To do this, add the --user option when running Pip. It seems you’ve already tried this; it’s not clear to me why it wouldn’t solve the problem, so this is unusual.


That said: in general, it’s best to run Pip as python -m pip, or py -m pip (depending on your system configuration) instead of just pip. Windows may have decided that ordinary users are not allowed to run the pip.exe executable at all. But if you can run Python, then you can run Pip this way (Pip is implemented in Python; python -m pip tells Python to run that module directly, instead of telling a wrapper program to start up a Python interpreter and use the code).

This way also makes sure you can control which copy of Python is used (in case you have more than one). When you do this, Python will use the copy of Pip that’s associated with it, and install libraries for that Python. When you try running pip, you are asking Windows to find the pip.exe program, and it will run and install for whichever Python installation, according to where Windows found the program.

Finally, on Windows, it’s necessary to use the python -m pip or py -m pip form when you use Pip to upgrade itself. The issue is that Windows does not allow running programs to replace themselves on disk, so pip install --upgrade pip will run into a permission error. If you do it the other way, python.exe is the running program instead, so there is no problem with rewriting the pip.exe file.