Comments (38)
For posterity: pyenv now supports fish! Try pyenv init
in a shell and it will tell you:
# Load pyenv automatically by adding
# the following to ~/.config/fish/config.fish:
status --is-interactive; and . (pyenv init -|psub)
from pyenv.
There's no need to use abandoned fisher plugin.
all you need is to paste this in your ~/.config/fish/config.fish :
set -x PYENV_ROOT $HOME/.pyenv
set -x PATH $PYENV_ROOT/bin $PATH
status --is-interactive; and . (pyenv init -|psub)
status --is-interactive; and . (pyenv virtualenv-init -|psub)
If you're pasting one line mentioned above:
status --is-interactive; and . (pyenv init -|psub)
you'll got the error:
~/.config/fish/config.fish (line 1): pyenv init -|psub
^
in command substitution
called on line -1 of file ~/.config/fish/config.fishfrom sourcing file ~/.config/fish/config.fish
called during startupsource: '.' command is deprecated, and doesn't work with STDIN anymore. Did you mean 'source' or './'?
because setting of PYENV_ROOT and PATH enviroment variables before the line which mentions pyenv is crucial!
from pyenv.
@yyuu pyenv
is awesome, thanks.
Also for posterity, I thought I'd write up a small guide about what's happening here:
status --is-interactive; and . (pyenv init - | psub)
First, status --is-interactive
sets the exit $status
code to 0 (true) if the terminal is interactive.
As for the -
, at least in Unix parlance, -
means standard input, but pyenv
uses it instead as a silent
flag to skip printing a help message that explains how to add pyenv
to your profile AFIK.
Now, psub
is used for process substitution. Let me explain this via an example, say you want to diff
two files:
diff file1 file2
but rather use a string like:
echo $string | diff file1 -
and with two strings:
diff (echo $s1 | psub) (echo $s2 | psub)
and translated to bash:
diff <($s1) <($s2)
In . (pyenv init - | psub)
, ``.' (a wrapper around the
source` builtin) will receive whatever comes out of `pyenv init -` as input.
.
evaluates (parses) the output produced by pyenv init...
, which is different from spawning a new process and running the output.
⚠️ .
is deprecated, please usesource
from now :)
This, among other things, creates the directories at $PYENV_ROOT/shims
, $PYENV_ROOT/versions
and sets up pyenv
environment.
from pyenv.
Thank you for the suggestion! In fish syntax it seems to be
set PYENV_ROOT $HOME/.pyenv
set -x PATH $PYENV_ROOT/shims $PYENV_ROOT/bin $PATH
pyenv rehash
The only problem is that modules that install stuff in bin
do not work properly. For example, if I install yolk
(a tool that generates a list of available modules), pip
correctly installs it in ~/.pyenv/versions/2.7.5/lib/python2.7/site-packages/
, and puts yolk
executable in ~/.pyenv/versions/2.7.5/bin/
, but when I call yolk
from the command line, it results in the call to /usr/local/bin/yolk
(the system one).
from pyenv.
Adding following snippet in your shell initialization script (something like ~/.profile
of sh for fish) might help you.
setenv PYENV_ROOT "${HOME}/.pyenv"
setenv PATH "${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
pyenv rehash
from pyenv.
@tiagofernandez
Oops. You're right. The initialization code has been changed during exporting this feature to rbenv (rbenv/rbenv#434).
Now I'm using following initialization code.
set -x PATH "$HOME/.pyenv/bin" $PATH
. (pyenv init - | psub)
from pyenv.
This doesn't work anymore in fish 3.1.0:
status --is-interactive; and . (pyenv init -|psub) status --is-interactive; and . (pyenv virtualenv-init -|psub)
And can be replaced until the issue is resolved (and it will work after that as well) with this in ~/.config/fish/config.fish:
status --is-interactive; and pyenv init - | source
status --is-interactive; and pyenv virtualenv-init - | source
As of this issue comment:
fish-shell/fish-shell#6613 (comment)
from pyenv.
The readme has already been updated to suggest source
instead of psub
for fish users.
from pyenv.
Sorry, yes fisher is alive but what I meant was the pyenv fisher package is abandoned
https://github.com/fisherman/pyenv
from pyenv.
I guess the initialization code for Fish is currently . (pyenv init -|psub)
, right?
Since eval (pyenv init - fish)
returns pyenv: no such command sh-'
.
from pyenv.
@sooheon Hmm. Can you post the error?
You are using the fisherman plugin right?
from pyenv.
If you run into other issues, please create an issue in the plugin's repo, fisherman's issue tracker or just contact me directly. Happy fishing! :)
from pyenv.
I'd like to support even for fish if it is available, but it seems somewhat difficult with current impl :(
Many of the code of pyenv is written in bash, but there are some of interactions between working shell. They might be the problem to support fish.
pyenv init
- need to prepare shell-specific init script
pyenv shell
export
is not workable on fish
- auto-completion
- need shell-specific code
from pyenv.
I'd personally be happy if init
worked, I don't really use 2 or 3. Do I understand it correctly that the primary function of init
is to call rehash
and add stuff to PATH
, and that's what makes global
/local
work?
from pyenv.
Yep, you're right. The global
and local
can work without init
.
from pyenv.
You might need pyenv rehash
to generate shim for yolk
after installing pip install yolk
. Plus, you might need to invoke something like rehash
(zsh) or hash -r
(bash) to update command table of the current shell.
from pyenv.
Oh, it seems that I did not quite understand what pyenv rehash
does. Thank you, that did help, no additional shell commands were necessary.
from pyenv.
Is there any other problem? Or, I wanna close this.
Updating Wiki about tips with fish is welcome :)
from pyenv.
Well, there's still an issue of shell
and auto-completion, which may be important for some people. Plus there are some weird problems of pip
running 2to3
when I install packages for Py2 and not running it when I install packages for Py3, which does not happen when I install them from their source directory (I cannot pinpoint the cause of this yet).
Basically, what I'm saying is, the issue of me using pyenv with fish is somewhat resolved, but the issue of pyenv supporting fish is not, so use your best judgement :) I will update the wiki as soon as I resolve the pip
problem.
from pyenv.
My decision on this is, pyenv
should even work on non-sh-style shells (like fish
and csh
), but init
, shell
and auto-completion
are limited on these shells.
Supporting full features on non-sh-style shells is very hard and will not be implemented. This does not mean it is impossible; it is possible if I wrote scripts like libexec/pyenv-init.fish
and completions/pyenv.fish
and some more. But I will not implement them because I am not an expert of these shells. (patches are welcome!)
Even if the support is limited, most of the features (like local
, global
and install
) are still available. I think this means pyenv
is still useful for the users of non-sh-style shells.
from pyenv.
Please describe more about the weird problems of pip running 2to3.
- Which python version did you use with?
- What is the package did you try to
pip install
? - Please paste the error output from pip
from pyenv.
For example:
~> pyenv global 2.7.5
~> pyenv rehash
~> pip install decorator -v
Downloading/unpacking decorator
Running setup.py egg_info for package decorator
running egg_info
writing pip-egg-info/decorator.egg-info/PKG-INFO
writing top-level names to pip-egg-info/decorator.egg-info/top_level.txt
writing dependency_links to pip-egg-info/decorator.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/decorator.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'documentation.py'
warning: no files found matching 'documentation3.py'
warning: no previously-included files found matching 'Makefile'
writing manifest file 'pip-egg-info/decorator.egg-info/SOURCES.txt'
Installing collected packages: decorator
Running setup.py install for decorator
running install
running build
running build_py
running install_lib
copying build/lib/decorator.py -> /Users/bogdan/.pyenv/versions/2.7.5/lib/python2.7/site-packages
byte-compiling /Users/bogdan/.pyenv/versions/2.7.5/lib/python2.7/site-packages/decorator.py to decorator.pyc
File "/Users/bogdan/.pyenv/versions/2.7.5/lib/python2.7/site-packages/decorator.py", line 158
print('Error in generated code:', file=sys.stderr)
^
SyntaxError: invalid syntax
running install_egg_info
running egg_info
writing src/decorator.egg-info/PKG-INFO
writing top-level names to src/decorator.egg-info/top_level.txt
writing dependency_links to src/decorator.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'src/decorator.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'documentation.py'
warning: no files found matching 'documentation3.py'
warning: no previously-included files found matching 'Makefile'
writing manifest file 'src/decorator.egg-info/SOURCES.txt'
Copying src/decorator.egg-info to /Users/bogdan/.pyenv/versions/2.7.5/lib/python2.7/site-packages/decorator-3.4.0-py2.7.egg-info
running install_scripts
writing list of installed files to '/var/folders/hq/kzp38x892h7g5nj6rr5p6d7c0000gn/T/pip-tDOBwU-record/install-record.txt'
Successfully installed decorator
Cleaning up...
Note the syntax error. If you look into https://pypi.python.org/packages/source/d/decorator/decorator-3.4.0.tar.gz you'll see a Py2-style print
statement there. If I download the sources, cd
there and run pip install .
, it installs correctly.
from pyenv.
Couldn't confirm this weird behaviour.
I think that there is something wrong in distutils or setuptools. The setup.py
running on 2.7.5 should not invoke 2to3
because the distutils
of 2.7.5 lacks distutils.util.Mixin2to3
. Setting the Python's environment variables of PYTHONHOME
or PYTHONPATH
might introduce this kind of confusion. But I'm not sure what is happening there :(
from pyenv.
I heard similar weird behaviour of 2to3
in #38. In that case, upgrading setuptools
from 0.7.2 to 0.9.7 (latest) solves the problem.
from pyenv.
Upgrading setuptools did not work for me, unfortunately. I have also found some other mentions of this problem (e.g. http://code.google.com/p/sympy/issues/detail?id=3437), and it seems that it is probably something related to pip
and not pyenv
. I'll close this for now, since this issue is quite elusive.
from pyenv.
Just for the sake of closure: the problem has been resolved by updating pip
from 1.3.1 to 1.4. Sorry for blaming pyenv
:)
from pyenv.
I noticed the update of pip by your mention here. Thanks for your comment :)
from pyenv.
@Manticore
I wrote some additional scripts to improve fish support of pyenv. The init
, shell
and completions are now working on fish. Please try fish-support
branch at pyenv repo.
https://github.com/yyuu/pyenv/tree/fish-support
Initialization code for fish.
setenv PATH "$HOME/.pyenv/bin" $PATH
eval (pyenv init - fish)
from pyenv.
Yep, everything seems to work, thank you!
from pyenv.
ok. I'll merge it into master
:)
from pyenv.
@bucaran: Thanks for that awesome explanation! Taught me about how psub
works.. cool!
from pyenv.
@BRJ with a recent version of fish, I'm getting source: '.' command is deprecated, and doesn't work with STDIN anymore. Did you mean 'source' or './'?
What is the form of this incantation without using .
, but source
directly?
from pyenv.
@sooheon Yes, use source
please.
.
is history now :)
from pyenv.
Sorry but my question was just about the syntax of how to do that--directly replacing .
with source
gives an error.
from pyenv.
I am now :). I had just copy pasted the snippet above in my fish.config before. Thanks.
from pyenv.
Looks like fisherman is abandoned. Any new alternatives?
from pyenv.
Updates ?
from pyenv.
Fisher is alive: https://github.com/jorgebucaran/fisher
from pyenv.
Related Issues (20)
- BUILD FAILED with or without using brew on WSL2 HOT 3
- Rehashing is not applied after pip install in venv
- pyenv init slows down the shell startup a bunch (by about ~100 ms!) HOT 3
- Python 3.12.2 support HOT 1
- VSCode Jupyter not working with Pyenv: solution
- pyenv fails to install Python 3.12.1/3.12.2 on Raspberry Pi Zero 2W running Bullseye Lite 64-Bit HOT 5
- "pyenv: python3.11: command not found" despite having selected a global version HOT 5
- Add PACKAGE_LDFLAGS to python-build
- Installing Pyenv on Ubuntu 20.04 (Azure ML instance) fails HOT 4
- `_curses` fails to build on Ubuntu 22: "error: implicit declaration of function ‘setcchar’; did you mean ‘getwchar’?" HOT 3
- ginstall: cannot stat 'Modules/readline.cpython-312-darwin.so': No such file or directory HOT 4
- [Workaround] Debian/Ubuntu - TKInter module fails to build even if tk-dev is installed HOT 1
- New release? (2.3.37) HOT 4
- Anaconda 2024.02-1
- Build failed at interpreteridobject.c:109:40 (macOS / arm64 / clang) HOT 2
- persistent SSL_get_peer_certificate when building Python 2.7 HOT 9
- running a python script in a pyenv environment with sudo or withing a systemd service HOT 2
- Custom manual installation within a dedicated 'build' directory, in a proot-distro alias of Debian chroot, in a Termux host environment: require `make install` instructions, post-successful BAT test, and successful custom make HOT 1
- PyPy 7.3.16? HOT 4
- /usr/bin/env: ‘bash\r’: Permission denied HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyenv.