2
I'm using venv for Python programming for the first time; so I'm assuming my difficulties are coming from that.
I've followed these instructions to create my virtual environment; which seemed to work flawlessly.
Next I followed along with this article but quickly ran into trouble. The command "pip install __" works; but curiously PowerShell seems to hang up after listing "Successfully installed...", pressing enter and spamming keystrokes does nothing; I have to close the PowerShell window. Waiting doesn't seem to do anything either.
After that happened; I figured I broke something so I tried to reinstall the module; in this case matplotlib first, and nmap second, just because nmap was the one I wanted to actually use.
Both returned, after hanging up on the "successful" install, some variation of "Requirement already satisfied: [details about install path here]"
My matplotlib output, for example:
Requirement already satisfied: matplotlib in c:\users\admin\environments\python1\lib\site-packages (3.1.1)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\admin\environments\python1\lib\site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: numpy>=1.11 in c:\users\admin\environments\python1\lib\site-packages (from matplotlib) (1.17.2)
Requirement already satisfied: cycler>=0.10 in c:\users\admin\environments\python1\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\admin\environments\python1\lib\site-packages (from matplotlib) (2.4.2)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\admin\environments\python1\lib\site-packages (from matplotlib) (2.8.0)
Requirement already satisfied: setuptools in c:\users\admin\environments\python1\lib\site-packages (from kiwisolver>=1.0.1->matplotlib) (40.8.0)
Requirement already satisfied: six in c:\users\admin\environments\python1\lib\site-packages (from cycler>=0.10->matplotlib) (1.12.0)
Which also hung up, curiously. It does seem to indicate the package was successfully installed though.
"pip freeze" ALSO supports the idea that these modules ARE installed right; and in my venv no less:
(python1) PS C:\Users\Admin\Environments> pip freeze
cycler==0.10.0
kiwisolver==1.1.0
matplotlib==3.1.1
nmap==0.0.1
numpy==1.17.2
pyparsing==2.4.2
python-dateutil==2.8.0
six==1.12.0
So again, I've never used a venv to program before - I only need to now to use an nmap module and play with some simple networking scripting; but from what I understand using virtual environments to code is the industry standard way of doing things; and thus I want to get the process right.
I'm running Python 3.7.4; and Python HAS been successfully added to PATH, confirmed by typing 'python' in command prompt - though from what I understand it shouldn't matter as each venv for a project is isolated and standalone.
Terribly appreciative of any kind of illumination anyone can provide.
Thank you for your insight. Would you have any suggested areas of reading or search terms for learning more about how pip may not be linked to the python interpreter I'm trying to use? Edit: As far as the Python install; I did a clean uninstall/reinstall to eliminate that issue, and checked that my Windows PATH is right -- so I don't think at least that that's the issue. – Spooky – 2019-09-17T23:34:36.123
Unfortunately, I don't know of any links off-hand. But
where python
andwhere pip
can return any paths currently available globally. Furthermore,pip
is always located in theScripts
folder of a given Python installation. SoC:\PythonA\python.exe
andC:\PythonA\Scripts\pip.exe
would be associated andC:\PythonA\python.exe
could use modules installed withC:\PythonA\Scripts\pip.exe.
C:\PythonA\python.exeand
C:\PythonB\pip.exewould not be associated and
C:\PythonA\python.execould not use modules installed with
C:\PythonB\pip.exe`. – Anaksunaman – 2019-09-18T00:00:03.390More generally, Python virtual environments work by temporarily overriding any existing path variables in a terminal session. So if a module is installed with
pip
into path A and path A is overridden or unavailable, then the module won't be able to be found. – Anaksunaman – 2019-09-18T00:04:41.720As a quick suggestion, I would try creating a new virtual environment, activating it, installing
nmap
in the exact same terminal window, then runpython
in that same window ,then runimport nmap
. If that doesn't work, then there may be other issues at play. – Anaksunaman – 2019-09-18T00:11:35.167Thank you @Anaksunaman, I'll try this as soon as I have time! – Spooky – 2019-09-19T18:52:09.260