精华内容
下载资源
问答
  • pyenv

    2017-05-25 17:00:06
    pyenv

    pyenv是个多版本python管理器,可以同时管理多个python版本共存,如pypy,miniconde等等

    安装

    $ git clone https://github.com/yyuu/pyenv.git ~/.pyenv
    $ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
    $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
    $ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
    $ exec $SHELL -l
    

    安装python

    $ pyenv install --list //查看可安装的python版本
    $ pyenv install 3.5.0 安装python3.5.0
    

    更新pyenv

    安装完之后,需要更新一下才能看到已经安装的版本

    $ pyenv rehash
    
    $ pyenv versions //查看已经安装好的版本,带*号的为当前使用的版本
    

    选择python版本

    $ pyenv global 3.5.0 //设置全局版本,即系统使用的将是此版本
    $ pyenv local 3.5.0 //当前目录下的使用版本,有点类似virtualenv
    

    ipthon的安装:
    1.先安装pip(我理解的pip相当于apt-get之类的),mac用easy_install,easy_install pip.
    2.安装ipthon,pip install ipython

    展开全文
  • Pyenv

    2020-10-26 14:08:30
    查看版本 pyenv versions 切换版本 pyenv global 3.6.8
    • 查看版本 pyenv versions
    • 切换版本 pyenv global 3.6.8
    展开全文
  • pyenv/pyenv

    2020-09-16 17:12:47
    pyenv lets you easily switch between multiple versions of Python. It’s simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well. This project was forked from...

    pyenv lets you easily switch between multiple versions of Python. It’s simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.

    This project was forked from rbenv and ruby-build, and modified for Python.

    Terminal output example

    pyenv does…
    Let you change the global Python version on a per-user basis.
    Provide support for per-project Python versions.
    Allow you to override the Python version with an environment variable.
    Search commands from multiple versions of Python at a time. This may be helpful to test across Python versions with tox.
    In contrast with pythonbrew and pythonz, pyenv does not…
    Depend on Python itself. pyenv was made from pure shell scripts. There is no bootstrap problem of Python.
    Need to be loaded into your shell. Instead, pyenv’s shim approach works by adding a directory to your $PATH.
    Manage virtualenv. Of course, you can create virtualenv yourself, or pyenv-virtualenv to automate the process.
    Table of Contents
    How It Works
    Understanding PATH
    Understanding Shims
    Choosing the Python Version
    Locating the Python Installation
    Installation
    Basic GitHub Checkout
    Upgrading
    Homebrew on macOS
    Advanced Configuration
    Uninstalling Python Versions
    Command Reference
    Development
    Version History
    License
    How It Works
    At a high level, pyenv intercepts Python commands using shim executables injected into your PATH, determines which Python version has been specified by your application, and passes your commands along to the correct Python installation.

    Understanding PATH
    When you run a command like python or pip, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called PATH, with each directory in the list separated by a colon:

    /usr/local/bin:/usr/bin:/bin
    Directories in PATH are searched from left to right, so a matching executable in a directory at the beginning of the list takes precedence over another one at the end. In this example, the /usr/local/bin directory will be searched first, then /usr/bin, then /bin.

    Understanding Shims
    pyenv works by inserting a directory of shims at the front of your PATH:

    $(pyenv root)/shims:/usr/local/bin:/usr/bin:/bin
    Through a process called rehashing, pyenv maintains shims in that directory to match every Python command across every installed version of Python—python, pip, and so on.

    Shims are lightweight executables that simply pass your command along to pyenv. So with pyenv installed, when you run, say, pip, your operating system will do the following:

    Search your PATH for an executable file named pip
    Find the pyenv shim named pip at the beginning of your PATH
    Run the shim named pip, which in turn passes the command along to pyenv
    Choosing the Python Version
    When you execute a shim, pyenv determines which Python version to use by reading it from the following sources, in this order:

    The PYENV_VERSION environment variable (if specified). You can use the pyenv shell command to set this environment variable in your current shell session.

    The application-specific .python-version file in the current directory (if present). You can modify the current directory’s .python-version file with the pyenv local command.

    The first .python-version file found (if any) by searching each parent directory, until reaching the root of your filesystem.

    The global $(pyenv root)/version file. You can modify this file using the pyenv global command. If the global version file is not present, pyenv assumes you want to use the “system” Python. (In other words, whatever version would run if pyenv weren’t in your PATH.)

    NOTE: You can activate multiple versions at the same time, including multiple versions of Python2 or Python3 simultaneously. This allows for parallel usage of Python2 and Python3, and is required with tools like tox. For example, to set your path to first use your system Python and Python3 (set to 2.7.9 and 3.4.2 in this example), but also have Python 3.3.6, 3.2, and 2.5 available on your PATH, one would first pyenv install the missing versions, then set pyenv global system 3.3.6 3.2 2.5. At this point, one should be able to find the full executable path to each of these using pyenv which, e.g. pyenv which python2.5 (should display $(pyenv root)/versions/2.5/bin/python2.5), or pyenv which python3.4 (should display path to system Python3). You can also specify multiple versions in a .python-version file, separated by newlines or any whitespace.

    Locating the Python Installation
    Once pyenv has determined which version of Python your application has specified, it passes the command along to the corresponding Python installation.

    Each Python version is installed into its own directory under $(pyenv root)/versions.

    For example, you might have these versions installed:

    $(pyenv root)/versions/2.7.8/
    $(pyenv root)/versions/3.4.2/
    $(pyenv root)/versions/pypy-2.4.0/
    As far as pyenv is concerned, version names are simply the directories in $(pyenv root)/versions.

    Managing Virtual Environments
    There is a pyenv plugin named pyenv-virtualenv which comes with various features to help pyenv users to manage virtual environments created by virtualenv or Anaconda. Because the activate script of those virtual environments are relying on mutating $PATH variable of user’s interactive shell, it will intercept pyenv’s shim style command execution hooks. We’d recommend to install pyenv-virtualenv as well if you have some plan to play with those virtual environments.

    Installation
    Homebrew on macOS
    Consider installing with Homebrew
    brew update
    brew install pyenv
    Then follow the rest of the post-installation steps under Basic GitHub Checkout, starting with #3 (“Add pyenv init to your shell to enable shims and autocompletion”).
    If you’re on Windows, consider using @kirankotari’s pyenv-win fork. (pyenv does not work on windows outside the Windows Subsystem for Linux)

    The automatic installer
    Visit my other project: https://github.com/pyenv/pyenv-installer

    Basic GitHub Checkout
    This will get you going with the latest version of pyenv and make it easy to fork and contribute any changes back upstream.

    Check out pyenv where you want it installed. A good place to choose is $HOME/.pyenv (but you can install it somewhere else).

    git clone https://github.com/pyenv/pyenv.git ~/.pyenv
    Define environment variable PYENV_ROOT to point to the path where pyenv repo is cloned and add $PYENV_ROOT/bin to your $PATH for access to the pyenv command-line utility.

    For bash:

    echo ‘export PYENV_ROOT=“ H O M E / . p y e n v " ′ > >   / . b a s h p r o f i l e e c h o ′ e x p o r t P A T H = " HOME/.pyenv"' >> ~/.bash_profile echo 'export PATH=" HOME/.pyenv">> /.bashprofileechoexportPATH="PYENV_ROOT/bin:$PATH”’ >> ~/.bash_profile
    For Ubuntu Desktop:

    echo ‘export PYENV_ROOT=“ H O M E / . p y e n v " ′ > >   / . b a s h r c e c h o ′ e x p o r t P A T H = " HOME/.pyenv"' >> ~/.bashrc echo 'export PATH=" HOME/.pyenv">> /.bashrcechoexportPATH="PYENV_ROOT/bin:$PATH”’ >> ~/.bashrc
    For Zsh:

    echo ‘export PYENV_ROOT=“ H O M E / . p y e n v " ′ > >   / . z s h r c e c h o ′ e x p o r t P A T H = " HOME/.pyenv"' >> ~/.zshrc echo 'export PATH=" HOME/.pyenv">> /.zshrcechoexportPATH="PYENV_ROOT/bin:$PATH”’ >> ~/.zshrc
    For Fish shell:

    set -Ux PYENV_ROOT $HOME/.pyenv
    set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths
    Proxy note: If you use a proxy, export http_proxy and HTTPS_PROXY too.

    Add pyenv init to your shell to enable shims and autocompletion. Please make sure eval “$(pyenv init -)” is placed toward the end of the shell configuration file since it manipulates PATH during the initialization.

    echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval “KaTeX parse error: Undefined control sequence: \nfi at position 16: (pyenv init -)"\̲n̲f̲i̲' >> ~/.bash_pr…(pyenv init -)” into .bash_profile, and not into .bashrc. Otherwise you may observe strange behaviour, such as pyenv getting into an infinite loop. See #264 for details.

    Restart your shell so the path changes take effect. You can now begin using pyenv.

    exec “$SHELL”
    Install Python build dependencies before attempting to install a new Python version.

    Install Python versions into $(pyenv root)/versions. For example, to download and install Python 2.7.8, run:

    pyenv install 2.7.8
    NOTE: If you need to pass configure option to build, please use CONFIGURE_OPTS environment variable.

    NOTE: If you want to use proxy to download, please use http_proxy and https_proxy environment variable.

    NOTE: If you are having trouble installing a python version, please visit the wiki page about Common Build Problems

    Upgrading
    If you’ve installed pyenv using homebrew, upgrade using:

    brew upgrade pyenv
    If you’ve installed pyenv using the instructions above, you can upgrade your installation at any time using git.

    To upgrade to the latest development version of pyenv, use git pull:

    cd $(pyenv root)
    git pull
    To upgrade to a specific release of pyenv, check out the corresponding tag:

    cd $(pyenv root)
    git fetch
    git tag
    git checkout v0.1.0
    Uninstalling pyenv
    The simplicity of pyenv makes it easy to temporarily disable it, or uninstall from the system.

    To disable pyenv managing your Python versions, simply remove the pyenv init line from your shell startup configuration. This will remove pyenv shims directory from PATH, and future invocations like python will execute the system Python version, as before pyenv.
    pyenv will still be accessible on the command line, but your Python apps won’t be affected by version switching.

    To completely uninstall pyenv, perform step (1) and then remove its root directory. This will delete all Python versions that were installed under $(pyenv root)/versions/ directory:

    rm -rf $(pyenv root)
    If you’ve installed pyenv using a package manager, as a final step perform the pyenv package removal. For instance, for Homebrew:

    brew uninstall pyenv
    Advanced Configuration
    Skip this section unless you must know what every line in your shell profile is doing.

    pyenv init is the only command that crosses the line of loading extra commands into your shell. Coming from rvm, some of you might be opposed to this idea. Here’s what pyenv init actually does:

    Sets up your shims path. This is the only requirement for pyenv to function properly. You can do this by hand by prepending $(pyenv root)/shims to your $PATH.

    Installs autocompletion. This is entirely optional but pretty useful. Sourcing $(pyenv root)/completions/pyenv.bash will set that up. There is also a $(pyenv root)/completions/pyenv.zsh for Zsh users.

    Rehashes shims. From time to time you’ll need to rebuild your shim files. Doing this on init makes sure everything is up to date. You can always run pyenv rehash manually.

    Installs the sh dispatcher. This bit is also optional, but allows pyenv and plugins to change variables in your current shell, making commands like pyenv shell possible. The sh dispatcher doesn’t do anything crazy like override cd or hack your shell prompt, but if for some reason you need pyenv to be a real script rather than a shell function, you can safely skip it.

    To see exactly what happens under the hood for yourself, run pyenv init -.

    Uninstalling Python Versions
    As time goes on, you will accumulate Python versions in your $(pyenv root)/versions directory.

    To remove old Python versions, pyenv uninstall command to automate the removal process.

    Alternatively, simply rm -rf the directory of the version you want to remove. You can find the directory of a particular Python version with the pyenv prefix command, e.g. pyenv prefix 2.6.8.

    Command Reference
    See COMMANDS.md.

    Environment variables
    You can affect how pyenv operates with the following settings:

    name default description
    PYENV_VERSION Specifies the Python version to be used.
    Also see pyenv shell
    PYENV_ROOT ~/.pyenv Defines the directory under which Python versions and shims reside.
    Also see pyenv root
    PYENV_DEBUG Outputs debug information.
    Also as: pyenv --debug
    PYENV_HOOK_PATH see wiki Colon-separated list of paths searched for pyenv hooks.
    PYENV_DIR $PWD Directory to start searching for .python-version files.
    PYTHON_BUILD_ARIA2_OPTS Used to pass additional parameters to aria2.
    If the aria2c binary is available on PATH, pyenv uses aria2c instead of curl or wget to download the Python Source code. If you have an unstable internet connection, you can use this variable to instruct aria2 to accelerate the download.
    In most cases, you will only need to use -x 10 -k 1M as value to PYTHON_BUILD_ARIA2_OPTS environment variable
    Development
    The pyenv source code is hosted on GitHub. It’s clean, modular, and easy to understand, even if you’re not a shell hacker.

    Tests are executed using Bats:

    bats test
    bats/test/.bats
    Please feel free to submit pull requests and file bugs on the issue tracker.

    Version History
    See CHANGELOG.md.

    License
    The MIT License

    展开全文
  • Simple Python Version Management: pyenv pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one...
  • pyenv 安装 ,一个简单的Python版本管理器。 在macOS上,安装是通过Homebrew完成的。 在Linux上, pyenv存储库是通过git克隆的。 要求 git install在MacOS上安装了Homebrew。 角色变量 姓名 默认值 描述 pyenv_repo...
  • zsh-pyenv zsh的zsh-pyenv插件。 该项目是我们全面的zsh 插件的一部分。 它是100%开源的,并根据许可。 要求 这是一个插件列表,需要先安装才能享受此配置的所有好处: https://github.com/luismayta/zsh-core ...
  • pyenv-installer

    2019-10-26 14:30:53
    python 虚拟环境管理神器 pyenv 一键安装脚本
  • pyenv安装

    2019-09-05 11:43:33
    pyenv时用来管理开发环境python版本的工具,配合virtualenv可以搭建完善的python虚拟环境 安装: git clone https://github.com/pyenv/pyenv.git ~/.pyenv/ echo 'export PATH=~/.pyenv/bin:$PATH' >> .bashrc...

    pyenv时用来管理开发环境python版本的工具,配合virtualenv可以搭建完善的python虚拟环境

    安装:

    git clone https://github.com/pyenv/pyenv.git ~/.pyenv/
    echo 'export PATH=~/.pyenv/bin:$PATH' >> .bashrc
    echo 'export PYENV_ROOT=~/.pyenv' >> .bashrc
    echo 'eval "$(pyenv init -)"' >> .bashrc
    source .bashrc
    

    使用:

    pyenv install --list        # list 所有可安装版本  
    pyenv install 3.7.4       # 安装python-3.7.4
    pyenv shell 3.7.4         # 当前shell使用python-3.7.4   
    # pyenv local 3.7.4      # 当前路径使用python-3.7.4
    # pyenv global 3.7.4    # 全局使用 python-3.7.4
    pyenv which python     # 显示当前使用python的安装路径
    pyenv uninstall 3.7.4    # 卸载python-3.7.4
    

    网络存在问题时,可以手动下载python的tar.xz包,使用pyenv安装,具体方法时:

    	wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz ./
    	mv Python-3.7.4.tar.xz ~/.pyenv/cache
    	pyenv install 3.7.4
    
    注意:安装python时,若存在依赖库确实,缺啥补啥
    
    展开全文

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 7,641
精华内容 3,056
关键字:

pyenv