I need a little assistance with an issue I'm having with one of my venvs.
TLDR
With a fresh virtual environment created with pipenv, running pipenv run python --version returns the following message, along with the wrong python version:
Warning: the which -a system utility is required for Pipenv to find Python installations properly.
Please install it.
Python 3.9.7 <--- this should be 3.8.5
Activating the virtual environment and then running python --version shows the correct version, but this prevents me from running anything via pipenv run <any command> with the venv not activated, and also raises suspicion that something isn't quite right. This is on MacOS Big Sur 11.6
My Process
- Install my desired python version with
pyenv install 3.8.5:
$ pyenv install 3.8.5
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.5.tar.xz...
-> https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
Installing Python-3.8.5...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.8.5 to /Users/<me>/.pyenv/versions/3.8.5
Output of pyenv versions:
* system (set by /Users/<me>/.pyenv/version)
3.6.4
3.6.7
3.8.12
3.8.5
3.9.1
- Create new environment and install reqs from Pipfile with
pipenv install --dev. Pipfile contains
[requires]
python_full_version = "3.8.5"
Output:
Creating a virtualenv for this project...
Pipfile: /Users/<me>/dev/<project>/Pipfile
Using /Users/<me>/.pyenv/versions/3.8.5/bin/python3.8 (3.8.5) to create virtualenv...
⠦ Creating virtual environment...created virtual environment CPython3.8.5.final.0-64 in 325ms
creator CPython3Posix(dest=/Users/<me>/.local/share/virtualenvs/<project>-OYt9MQn5, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/<me>/Library/Application Support/virtualenv)
added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
✔ Successfully created virtual environment!
Virtualenv location: /Users/<me>/.local/share/virtualenvs/<project>-OYt9MQn5
Installing dependencies from Pipfile.lock (62a518)...
▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 108/108 — 00:00:50
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
- Try to run
pipenv run python --version(it finds the wrong one):
$ pipenv run python --version
Loading .env environment variables...
Warning: the which -a system utility is required for Pipenv to find Python installations properly.
Please install it.
Python 3.9.7
- Activate the shell, and run either the above command (with the same output), or just
python --version, since the shell is activated now, and it finds the correct version:
(<project>) $ pipenv shell
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Loading .env environment variables...
Launching subshell in virtual environment...
. /Users/<me>/.local/share/virtualenvs/<project>-OYt9MQn5/bin/activate
N/A: version "N/A -> N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
$ . /Users/ckz8780/.local/share/virtualenvs/<project>-OYt9MQn5/bin/activate
(<project>) $ python --version
Python 3.8.5
(<project>) $
FWIW, I have several other venvs I've created in the exact same way (or so I thought) which work fine. In those venvs, when I run pipenv run python --version with the venv deactivated, the which -a error isn't there and they find the right python version. In fact, even if I activate the shell in those venvs and run pipenv run python --version, it still works fine and finds the right one. The only difference in those venvs is the python version (two are using python v3.6.x, and two are using python v3.8.9). They all work as expected, but this one just will not seem to find the right version no matter what I do. I am pulling my hair out.
Any help is greatly appreciated!!!
Thanks