'PIP installing globally instead of virtual env

I normally code in R, but I am having to learn Python for a project and am struggling to get the environment set up. The issue I seem to be having is that I am unable to get packages to install into the environment, instead the are installing globally. I assume I have a setting wrong or something somewhere.

I checked that I am running pip from the venv and it seems to be.

(venv) Johns-MacBook-Pro:venv johncarty$ which pip
/Users/johncarty/Documents/VGP/pythonProject/venv/bin/pip

When I run

pip install dash

I get the following output on everything pip tries to install.

WARNING: Target directory /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dash_html_components already exists. Specify --upgrade to force replacement.

Edit to add output of pip debug --verbose

(venv) Johns-MacBook-Pro:pythonProject johncarty$ pip debug --verbose
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
pip version: pip 21.1.2 from /Users/johncarty/Documents/VGP/pythonProject/venv/lib/python3.7/site-packages/pip (python 3.7)
sys.version: 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) 
[Clang 6.0 (clang-600.0.57)]
sys.executable: /Users/johncarty/Documents/VGP/pythonProject/venv/bin/python
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: UTF-8
sys.platform: darwin
sys.implementation:
    name: cpython
'cert' config value: global
REQUESTS_CA_BUNDLE: None
CURL_CA_BUNDLE: None
pip._vendor.certifi.where(): /Users/johncarty/Documents/VGP/pythonProject/venv/lib/python3.7/site-packages/pip/_vendor/certifi/cacert.pem
pip._vendor.DEBUNDLED: False
vendored library versions:
    appdirs==1.4.4
    CacheControl==0.12.6
    colorama==0.4.4
    distlib==0.3.1
    distro==1.5.0 (Unable to locate actual module version, using vendor.txt specified version)
    html5lib==1.1
    msgpack==1.0.2 (Unable to locate actual module version, using vendor.txt specified version)
    packaging==20.9
    pep517==0.10.0
    progress==1.5
    pyparsing==2.4.7
    requests==2.25.1
    certifi==2020.12.05
    chardet==4.0.0
    idna==3.1
    urllib3==1.26.4
    resolvelib==0.7.0
    setuptools==44.0.0 (Unable to locate actual module version, using vendor.txt specified version)
    six==1.15.0
    tenacity==7.0.0 (Unable to locate actual module version, using vendor.txt specified version)
    toml==0.10.2
    webencodings==0.5.1 (Unable to locate actual module version, using vendor.txt specified version)
Compatible tags: 1336


Solution 1:[1]

To be sure you can use absolute paths:

/Users/johncarty/Documents/VGP/pythonProject/venv/bin/pip install dash

If you will be working on that project for a while, activate the virtual environment:

/Users/johncarty/Documents/VGP/pythonProject/venv/Scripts/activate.bat

or look for the activate.bat script in the above virtual env tree

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 marcanuy