question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pipenv shell getting wrong python version

See original GitHub issue

pipenv is installed for python3 only. I specify python3 when creating the environment in a new empty directory. pipenv run python --version correctly reports python3. But when I run pipenv shell from within that same directory, I get

$ python --version
Python 2.7.10

Here are complete steps, showing install locations and versions:

[shacker@shackmac dev]$ mkdir foobar
[shacker@shackmac dev]$ cd foobar
[shacker@shackmac foobar]$ which pipenv
/Library/Frameworks/Python.framework/Versions/3.6/bin/pipenv
[shacker@shackmac foobar]$ pipenv --version
pipenv, version 2018.05.18
[shacker@shackmac foobar]$ pipenv --python 3.6
Creating a virtualenv for this project…
Using /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m (3.6.3) to create virtualenv…
⠋Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/shacker/.local/share/virtualenvs/foobar-labP-NDG/bin/python3.6m
Also creating executable in /Users/shacker/.local/share/virtualenvs/foobar-labP-NDG/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /Users/shacker/.local/share/virtualenvs/foobar-labP-NDG
Creating a Pipfile for this project…
[shacker@shackmac foobar]$ pipenv run python --version
Python 3.6.3
[shacker@shackmac foobar]$ pipenv shell
Spawning environment shell (/bin/bash). Use 'exit' to leave.

bash-3.2$ . /Users/shacker/.local/share/virtualenvs/foobar-labP-NDG/bin/activate
/Users/shacker/dev/foobar
bash-3.2$ python --version
Python 2.7.10
bash-3.2$ ls -l
total 8
drwxr-xr-x   3 shacker  staff   102 May 22 08:03 ./
drwxr-xr-x  31 shacker  staff  1054 May 22 08:03 ../
-rw-r--r--   1 shacker  staff   138 May 22 08:03 Pipfile
bash-3.2$ echo $PIPENV_VENV_IN_PROJECT
[no return value]

This is only happening on one of my machines – others are fine. But I can’t figure out what’s different about this environment to cause this. Thanks for any suggestions.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
uranusjrcommented, May 24, 2018

Ah I think it’s the . one that caused trouble. . is a shell-built-in that sources files (the same as source in Bash, but works for all Bourne-derived shells). Aliasing it to something else is looking for trouble 😃

The reason “fancy” works is because the two modes use different initialisation strategies. Non-fancy (aka compat) uses . or source to inject things into the new shell; fancy uses environment variable manipulation from Python (i.e. modifying os.environ).

p.s. Aliasing .. is fine IMO.

0reactions
shackercommented, May 24, 2018

I was about to say “The only thing in my .bashrc are bash aliases.” Which is true, but then I commented them all out and tried again, and pipenv shell worked properly! Took a closer look at those aliases and found something (leftover from some online tip I found years ago) that made me wonder. Commented out just these two lines:

alias .='pwd'
alias ..='cd ..'

and sure enough, that was the culprit. Interesting. I don’t use that alias anyway, good riddance. File under “never replace existing system commands via aliases.” Thanks for your time guys, appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pipenv using wrong python with pyenv · Issue #729 - GitHub
pipenv is using python 3.5.3 instead of 3.6.2 for some reason $ pipenv --version ... run the following: $ pipenv shell $ pyenv...
Read more >
Frequently Encountered Pipenv Problems - Read the Docs
☤ My pyenv-installed Python is not found​​ Make sure you have PYENV_ROOT set correctly. Pipenv only supports CPython distributions, with version name like...
Read more >
pipenv · PyPI
Pipenv : Python Development Workflow for Humans. image CI image. Pipenv is a tool that aims to bring the best of all packaging...
Read more >
Pipenv using wrong interpreter : PY-54909 - JetBrains YouTrack
Setting the base interpreter in the pipenv environment appears to have no effect ... PythonSdkFlavor - Couldn't get interpreter version: process exited with ......
Read more >
Using Python environments in VS Code
To change the shell, see Integrated terminal - Terminal profiles. You can manually specify the path to the conda executable to use for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found