pyenv / pyenv-virtualenv Goto Github PK
View Code? Open in Web Editor NEWa pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)
License: MIT License
a pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)
License: MIT License
I can't seem to create a virtualenv without all the site packages being included. I used the --no-site-packages option and that worked fine last night. For some reason today, that option is no longer available. It says new envs will have no site packages included by default but it doesnt seem to be the case for me.
For starters, I must state that I'm new at working with python in virtual environments, so please forgive me if I'm missing something obvious.
I want to create isolated projects with different versions of python and python packages.
I installed pyenv and that seems to be working fine. I installed various versions of python and set "pyenv local 3.3.3" and when I check the python version, everything seems correct.
I then installed pyenv-virtualenv, since the documentation states that 'pyenv' does not manage the virtual environments and to use 'pyenv-virtualenv' to make it easier.
I ran brew the following command to install pyenv-virtualenv:
~>> brew install pyenv-virtualenv
and everything seemed to run ok.
I then created and changed into a new directory 'test'. I ran the command based on the documentation and get the following error:
Repo >> mkdir test
Repo >> cd test
test >> pyenv virtualenv 2.7.6 mytestenv
Could not find an activated virtualenv (required).
I was under the assumption that pyenv virtualenv would create a virtual environment called 'mytestenv' using python 2.7.6. I'm not sure if I need to add something to my .bash_profile in order to get this to work. I have a lot of stuff in there from before since I had previously installed the regular version of virtualenv and virtualenvwrapper.
Can someone please explain how this is supposed to be used so I do not get the error. I've looked online for a couple hours and can not seem to find clear documentation.
Thanks,
Carolyn
If eval "$(pyenv virtualenv-init -)"
is in my zshenv, every time a command finishes there is a delay of about a second. Even hitting the enter key to cause another prompt without entering a command is slow.
Judging by what init does to the shell, perhaps this is because this command is slow:
pyenv activate --no-error --verbose
I do not have PYENV_ACTIVATE set, so that branch of the init logic would be hit.
Hi!
I have been having some problems creating new virtualenvs using the pyenv-virtualenv plugin. If I issue the following command in terminal:
pyenv virtualenv 3.3.5 myenv
This is what the terminal outputs:
pyenv virtualenv [-f|--force] [-u|--upgrade] [VIRTUALENV_OPTIONS] <version> <virtualenv-name>
pyenv virtualenv --version
pyenv virtualenv --help
-u/--upgrade Upgrade existing virtualenv to use new version of Python,
assuming Python has been upgraded in-place.
-f/--force Install even if the version appears to be installed already
I'm certain that I am inputting the command correctly, as I have used this plugin before without any issues. I am running a fresh install of Ubuntu 14.04, and all of my pyenv packages are up to date. I'm hoping that this isn't just a stupid oversight on my part!
Matt
pyenv-virtualenv
does not seem to handle scripts that gets installed in the bin
directory. Albeit the installation procedure seems to be fine, the plugin does not actually export in the PATH
environment variable the bin
path.
For example if I try to install Twisted
, from the setup logs I can clearly see that scripts are correctly installed under /Users/whatever/.pyenv/versions/demo-2.7.5/bin/twistd
but the environment variable PATH
is not set to include the folder /Users/whatever/.pyenv/versions/demo-2.7.5/bin/
.
It seems like you can't use Tox to test against multiple Python versions inside of a virtualenv created with pyenv-virtualenv. From what I can tell, this is because activating a pyenv-virtualenv sets the PYENV_VERSION
to the named virtualenv, which makes all the other pythonX.Y shims invalid.
A complete example demonstrating this problem:
$> pyenv install 2.7.6
$> pyenv install 3.4.1
$> pyenv global 2.7.6 3.4.1
$> pyenv versions
system
* 2.7.6 (set by /Users/andy/.pyenv/version)
* 3.4.1 (set by /Users/andy/.pyenv/version)
# NOTE, installing tox "globally" here and running it
# against 2.7.6 and 3.4.1 works fine because both
#2.7.6 and 3.4.1 are "activated" in the non-virtualenv
# environment
$> pyenv virtualenv 2.7.6 redis-py
$> pyenv activate redis-py
$> pyenv versions
system
2.7.6
3.4.1
* redis-py (set by PYENV_VERSION environment variable)
# Now Tox (or any other program trying to call python3.4) will fail
$> python3.4
pyenv: python3.4: command not found
The `python3.4' command exists in these Python versions:
3.4.1
I've gotten around this problem by using pyenv-virtualenvwrapper, which doesn't seem to use the pyenv versions system to create the virtualenv and doesn't set the PYENV_VERSION environment variable.
It seems to fail installing pip. I got the following in ~/.pip/pip.log:
------------------------------------------------------------
-c run on Sat Nov 8 11:48:21 2014
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking setuptools
URLs to search for versions for setuptools:
Skipping link . (from -f); not a file
Skipping link /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages (from -f); not a file
Skipping link /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support (from -f); not a file
Skipping link file:///Users/valrus/.pyenv/cache/pip-1.5.6.tar.gz; wrong project name (not setuptools)
Skipping link file:///Users/valrus/.pyenv/cache/Python-2.7.7.tgz; wrong project name (not setuptools)
Found link file:///Users/valrus/.pyenv/cache/setuptools-5.0.tar.gz, version: 5.0
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/__pycache__; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/_markerlib; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/clonevirtualenv.py; unknown archive format: .py
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/easy_install.py; unknown archive format: .py
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/IPython; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/ipython-1.2.1-py3.4.egg-info; unknown archive format: .egg-info
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/pip; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/pip-1.5.4.dist-info; unknown archive format: .dist-info
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/pkg_resources.py; unknown archive format: .py
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/README; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/setuptools; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/setuptools-2.1.dist-info; unknown archive format: .dist-info
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/stevedore; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/stevedore-0.14.1-py3.4.egg-info; unknown archive format: .egg-info
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv-1.11.4.dist-info; unknown archive format: .dist-info
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv.py; unknown archive format: .py
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_clone-0.2.4-py3.4.egg-info; unknown archive format: .egg-info
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenvwrapper; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenvwrapper-4.2-py3.4-nspkg.pth; unknown archive format: .pth
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenvwrapper-4.2-py3.4.egg-info; unknown archive format: .egg-info
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/__init__.py; unknown archive format: .py
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/__pycache__; not a file
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl; wrong project name (not setuptools)
Found link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/setuptools-2.2-py2.py3-none-any.whl, version: 2.2
Local files found: /Users/valrus/.pyenv/cache/setuptools-5.0.tar.gz, /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/setuptools-2.2-py2.py3-none-any.whl
Using version 5.0 (newest of versions: 5.0, 2.2)
Running setup.py (path:/Users/valrus/.pyenv/versions/tweepy/build/setuptools/setup.py) egg_info for package setuptools
running egg_info
creating pip-egg-info/setuptools.egg-info
writing top-level names to pip-egg-info/setuptools.egg-info/top_level.txt
writing requirements to pip-egg-info/setuptools.egg-info/requires.txt
writing dependency_links to pip-egg-info/setuptools.egg-info/dependency_links.txt
writing entry points to pip-egg-info/setuptools.egg-info/entry_points.txt
writing pip-egg-info/setuptools.egg-info/PKG-INFO
writing manifest file 'pip-egg-info/setuptools.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/setuptools.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/setuptools.egg-info/SOURCES.txt'
Source in /Users/valrus/.pyenv/versions/tweepy/build/setuptools has version 5.0, which satisfies requirement setuptools
skipping extra certs
skipping extra ssl:sys_platform=='win32'
Downloading/unpacking pip
URLs to search for versions for pip:
Found link file:///Users/valrus/.pyenv/cache/pip-1.5.6.tar.gz, version: 1.5.6
Skipping link file:///Users/valrus/.pyenv/cache/Python-2.7.7.tgz; wrong project name (not pip)
Skipping link file:///Users/valrus/.pyenv/cache/setuptools-5.0.tar.gz; wrong project name (not pip)
Found link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl, version: 1.5.4
Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/setuptools-2.2-py2.py3-none-any.whl; wrong project name (not pip)
Local files found: /Users/valrus/.pyenv/cache/pip-1.5.6.tar.gz, /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl
Using version 1.5.6 (newest of versions: 1.5.6, 1.5.4)
Running setup.py (path:/Users/valrus/.pyenv/versions/tweepy/build/pip/setup.py) egg_info for package pip
/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'tests_require'
warnings.warn(msg)
/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'extras_require'
warnings.warn(msg)
/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'entry_points'
warnings.warn(msg)
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'egg_info'
Complete output from command python setup.py egg_info:
/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'tests_require'
warnings.warn(msg)
/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'extras_require'
warnings.warn(msg)
/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'entry_points'
warnings.warn(msg)
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'egg_info'
----------------------------------------
Cleaning up...
Removing temporary dir /Users/valrus/.pyenv/versions/tweepy/build...
Command python setup.py egg_info failed with error code 1 in /Users/valrus/.pyenv/versions/tweepy/build/pip
Exception information:
Traceback (most recent call last):
File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/req.py", line 325, in run_egg_info
command_desc='python setup.py egg_info')
File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/util.py", line 697, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command python setup.py egg_info failed with error code 1 in /Users/valrus/.pyenv/versions/tweepy/build/pip
Is it possible to have a post install hook so that every time a new virtualenv is created a package is installed too?
The use case is simple: i'd like - in the same way pip is installed - to have iPython installed automatically with every pyenv virtualenv created.
There are several issues with the virtualenv's activate script, especially with its handling of $PATH
(pypa/virtualenv#722).
Since it's basically rather trivial for what it does, I think it would be a good idea for pyenv-virtualenv to not use it, but do the setup / restoring itself.
Other issues: pypa/virtualenv#724, pypa/virtualenv#723.
I had this line eval "$(pyenv virtualenv-init -)"
in my .zshrc
, and ran source .zshrc
and received the above error.
Am I missing anything?
With the default python2.7 it works fine, but it fails when I specify python3
Both pythons, pyenv and pyenv-virtualenv have been installed through brew.
The error message seems quite clear but I don't have a clue how to solve it.
$ pyenv virtualenv --python=/usr/local/bin/python3 matrix
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4'
New python executable in /Users/hernan/.pyenv/versions/matrix/bin/python3.4
Also creating executable in /Users/hernan/.pyenv/versions/matrix/bin/python
Failed to import the site module
Traceback (most recent call last):
File "/Users/hernan/.pyenv/versions/matrix/bin/../lib/python3.4/site.py", line 67, in <module>
import os
File "/Users/hernan/.pyenv/versions/matrix/bin/../lib/python3.4/os.py", line 614, in <module>
from _collections_abc import MutableMapping
ImportError: No module named '_collections_abc'
ERROR: The executable /Users/hernan/.pyenv/versions/matrix/bin/python3.4 is not functioning
ERROR: It thinks sys.prefix is '/Users/hernan/.pyenv/cache' (should be '/Users/hernan/.pyenv/versions/matrix')
ERROR: virtualenv is not compatible with this system or executable
$
I have two system Pythons installed: 2.7.5 and 3.2. When creating a virtual env:
pyenv virtualenv system foo
I can't select which one to use. The default (2.7.5) is always used. I tried aliasing:
~$ alias python=python3
~$ pyenv virtualenv system foo
I also tried changing the python
shim to always run python3
by changing the last line to:
exec "/home/tomas/.pyenv/libexec/pyenv" exec "python3" "$@"
right before creating the virtual env. In both cases, version 2.7.5 was still used. Creating the virtual env manually worked:
~$ pyenv shell system
~$ virtualenv -p `pyenv which python3` --system-site-packages .pyenv/versions/photo_organizer
Some times we just want to try some library, it would be nice to have something along the lines of the following to easily create a disposable environment.
#!/bin/sh
# TODO: generate a unique name if none given
# TODO: allow to define a base environment
pyenv virtualenv "$1"
echo "Entering a new shell session with version '$1'"
echo "Press ctrl+d or exit to terminate it"
export PYENV_VERSION="$1"
$SHELL
echo "Destroying temp version '$1'"
pyenv uninstall -f "$1"
I installed python 2.7.6 and python 3.3.3 with pyenv.
Now when I run brew doctor
I get the following warning:
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Users/insomniac/.pyenv/shims/python-config
/Users/insomniac/.pyenv/shims/python2-config
/Users/insomniac/.pyenv/shims/python2.7-config
/Users/insomniac/.pyenv/shims/python3-config
/Users/insomniac/.pyenv/shims/python3.3-config
/Users/insomniac/.pyenv/shims/python3.3m-config
How can this be fixed so it plays nice with brew?
C.
If I install pyenv-virtualenv
, it will report error every time I switch python env.
$ pyenv shell anaconda3-2.1.0
pyenv-virtualenv: activate anaconda3-2.1.0
Error: did not expect more than one argument.
I have a project in which I created a .python-version
file. In this case I have something like:
$ cat project/.python-version
project-2.7.8
Whenever I change my directory to the project root pyenv-virtualenv is invoked correctly. When I leave the virtual env is deactivated.
$ cd project
pyenv-virtualenv: activate project-2.7.8
(project-2.7.8) $ cd ..
pyenv-virtualenv: deactivate project-2.7.8
The problem is that if I re-enter in the project/
directory is not activated anymore.
$ cd project
# Nothing happens
$
It doesn't matter how many times I try, the activation seems to work only once. Successive attempts seem to ignore the virtualenv indicated in the .python-version
file.
Hey there, I've noticed that activating a virtualenv on the fish shell doesn't work. I tested this with a fresh Ubuntu 14.04 install and a new copy of pyenv.
fots@fotsies-ubtrusty-01~> pyenv global 2.7.6
fots@fotsies-ubtrusty-01~> pyenv virtualenv flaskage
Downloading/unpacking virtualenv
Downloading virtualenv-1.11.6-py2.py3-none-any.whl (1.6MB): 1.6MB downloaded
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
New python executable in /home/fots/.pyenv/versions/flaskage/bin/python
Installing setuptools, pip...done.
fots@fotsies-ubtrusty-01~> pyenv activate flaskage
pyenv: version `/home/fots/.pyenv/versions/flaskage/bin/activate.fish' not installed
fots@fotsies-ubtrusty-01~>
Activating the virtualenv manually seems to work:
fots@fotsies-ubtrusty-01~> . /home/fots/.pyenv/versions/flaskage/bin/activate.fish
(flaskage)fots@fotsies-ubtrusty-01~> which python
/home/fots/.pyenv/versions/flaskage/bin/python
(flaskage)fots@fotsies-ubtrusty-01~> pyenv deactivate
fots@fotsies-ubtrusty-01~>
Your help on this would be greatly appreciated! 😄
Fotis
$ pyenv activate <TAB>
This insert additional space at each TAB
hit. But I expect a list of my virtualenvs :)
I've already installed few virtualenvs (those virtualenvs are listed down when i check pyenv virtualenvs in /usr/local/opt/pyenv/versions)
In zshrc i've added these lines
export PYENV_ROOT="/usr/local/opt/pyenv"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
$PYENV_ROOT is available in shell
echo $PYENV_ROOT : /usr/local/opt/pyenv
But if i try to install new pyenv version and using it creating a new virtualenv, the installation goes in different folder (i guess default) ~/.pyenv
Because of that my new virtualenv is not available (in pyenv virtualenvs, hence i can't use it)
Hi there,
I found there is no 'VIRTUAL_ENV' environment variable which is used by jedi library
https://github.com/davidhalter/jedi/blob/master/jedi/evaluate/sys_path.py#L13
Could you prefer to add this one ? For example, I have a virtualenv in ~/.pyenv/versions/web/
. The VIRTUAL_ENV
will be ~/.pyenv/versions/web/
, so that ~/.pyenv/versions/web/lib/python2.7/site-packages
will be added into sys.path
when jedi loads. Jedi will autocomplete the packages in that folder.
My environment : pyenv-virtualenv + jedi-vim
Hey there Yuu, hope you're well 😄
Since some of the latest commits, I've been having quite a few major problems with this extension I'm afraid.
My test system is a fresh install of Ubuntu Server 12.04 with the regular bash shell.
This output should explain the problems 😄
fots@fotsies-ubprecise-02:~$ pyenv versions
* system (set by /home/fots/.pyenv/version)
2.7.7
3.4.1
fots@fotsies-ubprecise-02:~$ python -V
Python 2.7.3
fots@fotsies-ubprecise-02:~$ pyenv global 2.7.7
fots@fotsies-ubprecise-02:~$ python -V
Python 2.7.7
fots@fotsies-ubprecise-02:~$ pyenv virtualenv newproject
New python executable in /home/fots/.pyenv/versions/newproject/bin/python
Installing setuptools, pip...done.
fots@fotsies-ubprecise-02:~$ pyenv activate newproject
(newproject)fots@fotsies-ubprecise-02:~$ python -V
Python 2.7.3
(newproject)fots@fotsies-ubprecise-02:~$ pyenv deactivate
(newproject)fots@fotsies-ubprecise-02:~$ unset PYENV_VERSION
fots@fotsies-ubprecise-02:~$ pyenv virtualenv 2.7.7 newproject2
New python executable in /home/fots/.pyenv/versions/newproject2/bin/python
Installing setuptools, pip...done.
fots@fotsies-ubprecise-02:~$ pyenv activate newproject2
(newproject2)fots@fotsies-ubprecise-02:~$ python -V
Python 2.7.3
(newproject2)fots@fotsies-ubprecise-02:~$
So in summary:
Your help would be greatly appreciated
Fotis
I'm trying to install a virtual environment that uses UCS-4 encoding. I've installed my base python installation with:
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs4" pyenv install 2.7.5
mv $PYENV_ROOT/versions/2.7.5 $PYENV_ROOT/versions/2.7.5_ucs4
pyenv install 2.7.5
pyenv global 2.7.5_ucs4
If I run python -c "import sys; print sys.maxunicode"
, it prints 1114111
, indicating that UCS-4 is installed. When I then run:
pyenv virtualenv vEnv
pyenv local vEnv
python -c "import sys; print sys.maxunicode"
it prints out 65535
, indicating UCS-2 is installed.
Should I be doing something differently?
I am using Python 3.4.1 and installed pyenv manually and via homebrew on my Mac OSX running v 10.9.3. After creating a virtualenv and then activating it, which all works. I have a problem with deactivating. When I run 'pyenv deactivate' nothing happens and my shell still shows me as being in the virtualenv.
Any ideas to fix this? Thanks. If I do 'pyenv shell --unset' while in a virtualenv works to 'deactivate'.
Running pyenv deactivate in debug. Hiding my directory name from web scrapers.
++ [pyenv:15] type -p greadlink readlink
++ [pyenv:15] head -1
Hi everyone, I didn't find where to fix it.. in my pc I'm uninstalling / installing by hand with:
$ pyenv global 2.4.6
$ pip uninstall virtualenv
$ easy_install virtualenv==1.7.2
Could you please fix the version of virtualenv with python 2.4.6?
On OpenSuse 12.1 with a custom pyenv home path.
There's no error :
pyenv virtualenv 2.6.8 custom_py2.6.8_2
New python executable in /datas/libs/pyenv/versions/custom_py2.6.8_2/bin/python
Installing setuptools, pip...done.
The new env directory isn't created in .../versions and isn't listed by pyenv versions.
The same command is ok with v20140110.1 tag.
Versions :
In my current oh-my-fish theme (numist) I type command in the second line, but when I activate my pyenv-virtualenv it breaks and goes back to the same line as the other info. Check the screenshot for details.
I tried to upgrade 3.4.1 based virtualenv to 3.4.2:
Alexanders-MacBook-Air:~ lorddaedra$ pyenv virtualenv 3.4.2 byvshie
pyenv-virtualenv: /Users/lorddaedra/.pyenv/versions/byvshie already exists
continue with installation? (y/N) y
but it's still has python3.4 symlink to 3.4.1(not 3.4.2 as expected)
(byvshie) Alexanders-MacBook-Air:~ lorddaedra$ ls -al ~/.pyenv/versions/byvshie/bin/
total 272
drwxr-xr-x 34 lorddaedra staff 1156 15 окт 13:56 .
drwxr-xr-x 6 lorddaedra staff 204 15 окт 13:56 ..
drwxr-xr-x 8 lorddaedra staff 272 15 окт 13:56 __pycache__
-rw-r--r-- 1 lorddaedra staff 2163 16 окт 02:56 activate
-rw-r--r-- 1 lorddaedra staff 1279 16 окт 02:56 activate.csh
-rw-r--r-- 1 lorddaedra staff 2415 16 окт 02:56 activate.fish
-rwxr-xr-x 1 lorddaedra staff 305 4 сен 14:49 django-admin
-rwxr-xr-x 1 lorddaedra staff 164 4 сен 14:49 django-admin.py
-rwxr-xr-x 1 lorddaedra staff 272 12 окт 16:43 easy_install
-rwxr-xr-x 1 lorddaedra staff 272 12 окт 16:43 easy_install-3.4
-rwxr-xr-x 1 lorddaedra staff 3670 2 окт 04:34 jwt
-rw-r--r-- 1 lorddaedra staff 2369 15 окт 13:56 pilconvert.py
-rw-r--r-- 1 lorddaedra staff 15636 15 окт 13:56 pildriver.py
-rw-r--r-- 1 lorddaedra staff 2614 15 окт 13:56 pilfile.py
-rw-r--r-- 1 lorddaedra staff 1060 15 окт 13:56 pilfont.py
-rw-r--r-- 1 lorddaedra staff 2415 15 окт 13:56 pilprint.py
-rwxr-xr-x 1 lorddaedra staff 244 17 июн 23:46 pip
-rwxr-xr-x 1 lorddaedra staff 244 17 июн 23:46 pip3
-rwxr-xr-x 1 lorddaedra staff 244 17 июн 23:46 pip3.4
lrwxr-xr-x 1 lorddaedra staff 9 17 июн 23:46 python -> python3.4
lrwxr-xr-x 1 lorddaedra staff 9 17 июн 23:46 python3 -> python3.4
lrwxr-xr-x 1 lorddaedra staff 53 17 июн 23:46 python3.4 -> /Users/lorddaedra/.pyenv/versions/3.4.1/bin/python3.4
-rwxr-xr-x 1 lorddaedra staff 331 15 окт 13:56 raven
-rwxr-xr-x 1 lorddaedra staff 633 6 окт 17:56 rst2html.py
-rwxr-xr-x 1 lorddaedra staff 830 6 окт 17:56 rst2latex.py
-rwxr-xr-x 1 lorddaedra staff 639 6 окт 17:56 rst2man.py
-rwxr-xr-x 1 lorddaedra staff 803 6 окт 17:56 rst2odt.py
-rwxr-xr-x 1 lorddaedra staff 1737 6 окт 17:56 rst2odt_prepstyles.py
-rwxr-xr-x 1 lorddaedra staff 640 6 окт 17:56 rst2pseudoxml.py
-rwxr-xr-x 1 lorddaedra staff 676 6 окт 17:56 rst2s5.py
-rwxr-xr-x 1 lorddaedra staff 825 6 окт 17:56 rst2xetex.py
-rwxr-xr-x 1 lorddaedra staff 641 6 окт 17:56 rst2xml.py
-rwxr-xr-x 1 lorddaedra staff 709 6 окт 17:56 rstpep2html.py
-rwxr-xr-x 1 lorddaedra staff 3891 12 окт 16:43 sqlformat
(byvshie) Alexanders-MacBook-Air:~ lorddaedra$
I wanted to just confirm that there isn't any automatic facility in pyenv or pyenv-virtualenv for hooks like the way virtualenvwrapper provides postactivate
and postdeactivate
scripts. I'm mostly interested in the setting of environment variables when a version activates.
I'm fine with leaving virtualenvwrapper behind (or else I'd play with pyenv-virtualenvwrapper), but I figured I should find out for sure if there is any similar functionality available to me. I didn't see anything along these lines on https://github.com/yyuu/pyenv/wiki/Plugins
Thanks in advance for any info one way or the other!
:~[103] > pyenv versions
system
3.4.1
jython-2.5.3
:~[104] > python --version
Python 2.7.8
:~[105] > pyenv global 3.4.1
:~[106] > pyenv versions
system
* 3.4.1 (set by /Users/christoperjung/.pyenv/version)
jython-2.5.3
:~[107] > python --version
Python 2.7.8
It seems like pyenv global's not working properly. How can I fix this issue?
I'm running Mac 10.9.5 and i did the installation as below:
brew install pyenv
eval "$(pyenv init -)" >> ~/.bashrc
brew install pyenv-virtualenv
eval "$(pyenv virtualenv-init -)" >> ~/.bashrc
The installation home is all under
pyenv versions
* system (set by /usr/local/opt/pyenv/version)
3.4.2
ra1
[dani@localhost in ~]# ll /usr/local/opt/pyenv*
lrwxr-xr-x 1 dani admin 24B Oct 22 16:27 /usr/local/opt/pyenv -> ../Cellar/pyenv/20141012
lrwxr-xr-x 1 dani admin 35B Oct 22 16:38 /usr/local/opt/pyenv-virtualenv -> ../Cellar/pyenv-virtualenv/20141012
I read the other issues - #47 , #48, #32 , #33 and i've followed the same steps as in #32 (i get this are the manual steps)
[dani@localhost in ~]# pyenv versions
* system (set by /usr/local/opt/pyenv/version)
3.4.2
ra1
[dani@localhost in ~]# python -V
Python 2.7.6
[dani@localhost in ~]# echo PYENV_ACTIVATED
PYENV_ACTIVATED
[dani@localhost in ~]# echo $PYENV_ACTIVATED
[dani@localhost in ~]# echo $PYENV_DEACTIVATED
[dani@localhost in ~]# echo $PYENV_VIRTUALENV_INIT
1
[dani@localhost in ~]# pyenv activate ra1
(ra1) [dani@localhost in ~]# python -V
Python 3.4.2
(ra1) [dani@localhost in ~]# echo $PYENV_ACTIVATED
(ra1) [dani@localhost in ~]# echo $PYENV_DEACTIVATED
(ra1) [dani@localhost in ~]# echo $PYENV_VERSION
ra1
(ra1) [dani@localhost in ~]# pyenv deactivate
[dani@localhost in ~]# echo $PYENV_VERSION
ra1
[dani@localhost in ~]# echo $PYENV_DEACTIVATED
[dani@localhost in ~]# echo $PYENV_ACTIVATED
[dani@localhost in ~]# pyenv version
ra1 (set by PYENV_VERSION environment variable)
[dani@localhost in ~]# pyenv versions
system
3.4.2
* ra1 (set by PYENV_VERSION environment variable)
[dani@localhost in ~]#
BUT because the above behavior, when i'm trying to uninstall the virtual env i get this error
[dani@localhost in ~]# pyenv uninstall ra1
pyenv: remove /usr/local/opt/pyenv/versions/ra1? y
[dani@localhost in ~]# pyenv versions
pyenv: version `ra1' is not installed
system
3.4.2
In #47 you mentioned,
As you mentioned, PYENV_DEACTIVATED should not persist after automatically triggered deactivation. I'll try to fix it in #47.
hence my question: _what is the working flow for the auto activation/ deactivation? Do i need to be inside the PYENV_ROOT in order for auto activation to kick in?_
In addition to this issue, according to the README file, the pyenv-virtualenv should be registered as a plugin inside pyenv, is this a bug in the brew formula's installation?
[dani@localhost in ~]# ll /usr/local/opt/pyenv/plugins/
total 8
lrwxr-xr-x 1 dani admin 61B Oct 22 16:27 python-build -> /usr/local/Cellar/pyenv/20141012/default-plugins/python-build
I activate an virtualenv called study3
with the command pyenv activate study3
. In this time, I have my python in the version of study3
Then I want to deactivate study3
and I input the command pyenv deactivate study3
or pyenv deactivate study3
and I get no result. I still have the version of study3
.
Is there anything I did wrong or do I have some misunderstanding about the command?
While working on different library version it would be extremely helpful to be able to clone an existing virtualenv.
Right now what I do is:
pip freeze > requirements.txt
in the current virtualenvpyenv virtualenv ...
pyenv shell newvirtualenv
pip install -r requirements.txt
Not too bad, but it could be easier.
What command to remove a virtualenv?
When running $ eval "$(pyenv virtualenv-init -)"
, I always get this error message:
Failed to deactivate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
For some reason, I can still use it on the same shell I installed it in, but not any other shell. How do I load up pyenv-virtualenv properly? Note: I Installed it using Homebrew.
I just realised I have issues with my virtualenv:
$ python
-bash: /Users/ncopty/.pyenv/versions/finprod/bin/python: No such file or directory
$ ~/.virtualenvs/finprod/bin/python
Python 2.7.2 (default, Jul 2 2014, 14:30:17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.34.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Which one is the correct one and why do I have two?
Hi,
I just installed a 3.3.5 version in pyenv on a Debian Wheezy. Then I made a virtualenv using pyenv-virtualenv. And the last part, I did a pip install -r requirements.txt.
And I got this error while installing a dependancy:
subprocess.CalledProcessError: Command '['2to3', '-wn', 'build/lib/logilab/common/test/data']' returned non-zero exit status 127
When I execute 2to3 command, I have this result:
(tickets) root@infra-tool01:/srv/tickets/tickets# 2to3
pyenv: 2to3: command not found
The `2to3' command exists in these Python versions:
3.3.5
It seems 2to3 command executed is the one in shims:
(tickets) root@infra-tool01:/srv/tickets/tickets# which 2to3
/srv/tickets/pyenv/shims/2to3
Here is my $PATH:
(tickets) root@infra-tool01:/srv/tickets/tickets# echo $PATH
/srv/tickets/pyenv/versions/tickets/bin:/srv/tickets/pyenv/shims:/srv/tickets/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
I did a pyenv rehash outside and inside the virtualenv, nothing changed.
Any idea?
Best regards,
Alexis.
I am having trouble activating a virtual environment with "pyenv activate".
I restarted my machine and am working in a fresh shell.
I have pyenv
installed and it appears to be working correctly.
~ >> pyenv versions
system
* 2.7.6 (set by /Users/insomniac/.pyenv/version)
3.3.3
I create a new project and set the python version with pyenv:
>> mkdir myproj
>> cd myproj
myproj >> pyenv local 3.3.3
myproj >> pyenv local
3.3.3
I then create a virtualenv called "foo" and double check it was created
myproj >> pyenv virtualenv foo333
myproj >> pyenv virtualenvs
foo333 (created from /Users/insomniac/.pyenv/versions/3.3.3)
If I list pyenv versions
, it's showing in the list, so I assume the virtual environments are being saved in the same location (this is a bit confusing).
myproj >> pyenv versions
system
2.7.6
* 3.3.3 (set by /Users/insomniac/Repo/myproj/.python-version)
foo333
If I try to active the "foo333" virtual environment for "myproject" I get the following error:
myproj >> pyenv activate foo333
pyenv: no such command `activate'
I restart my shell and try again with the same result:
myproj >> pyenv local
3.3.3
myproj >> pyenv virtualenvs
foo333 (created from /Users/insomniac/.pyenv/versions/3.3.3)
myproj >> pyenv activate foo333
pyenv: no such command `activate'
myproj >>
I am able to activate 'foo333' with the following command:
myproj >> source "$(pyenv prefix foo333)/bin/activate"
(foo333) myproj >>
If I try to deactivate - I can only use "deactivate" - I get the same error if I use pyenv deactivate
(foo333) myproj >> pyenv deactivate
pyenv: no such command `deactivate'
(foo333) myproj >> deactivate
myproj >>
I installed pyenv-virtualenv this morning using "brew install".
Any ideas?
Thanks,
C.
Hi @yyuu! Love the tool, one question. Is the only way to remove a venv created by pyenv virtualenv
by deleting the folder in ~/.pyenv/versions
?
I wonder if it would be a good idea to use the chpwd
hook (instead of precmd
(for zsh)) with the hook that gets installed via pyenv virtualenv init -
:
_pyenv_virtualenv_hook () {
if [ -n "$PYENV_ACTIVATE" ]
then
if [ "$(pyenv version-name)" = "system" ]
then
pyenv deactivate --no-error --verbose
return 0
fi
if [ "$PYENV_ACTIVATE" != "$(pyenv prefix)" ]
then
if pyenv deactivate --no-error --verbose
then
pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE
else
pyenv activate --no-error --verbose
fi
fi
else
if [ -z "$VIRTUAL_ENV" ] && [ "$PYENV_DEACTIVATE" != "$(pyenv prefix)" ]
then
pyenv activate --no-error --verbose
fi
fi
}
Alternatively, pyenv itself could have a hook system, where changing the version (e.g. via pyenv shell
) would notify the pyenv-virtualenv plugin and that could call activate
then (based on some config).
If I activate any environment without pyenv shell env
then it'll automatically deactivated with next command
$ cd ~/data
$ virtualenv venv
$ . venv/bin/activate
$ echo $VIRTUAL_ENV
/home/user/data/venv
$ pip install pyflake8 #actually any command
$ echo $VIRTUAL_ENV
$ echo :(
My configuration
export PATH=$HOME/.pyenv/bin:$PATH
if type pyenv 1> /dev/null 2>&1
then
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
So I have a local python version within a folder (set by pyenv local 2.7.8
) and I also have created a virtualenv using this command: pyenv virtualenv 2.7.8 venv278
. (not active at the moment). Now I do pip list
and sure enough I get the right result. Now I activate the virtualenv like so: pyenv activate venv278
. and pip install
a package (let's say django). while the virtualenv is still active I do pip list
, and I see django package in the list. So far, so good. But when I deactivate the virtualenv and do pip list
again, I can still see django in the list. Which I think is wrong. However when I restart the terminal and go to that directory again and do pip list
(with virtualenv NOT activated yet) I get the correct result, i.e. the list without django!
I'm running mac os x (version 10.9.4) and installed pyenv through homebrew.
On OS X 10.8.5, running pyenv install anaconda-1.9.1
returns:
ERRORPrecompiled binary of anaconda-1.9.1 is not available for Darwin-x86_64.
It appears that what should happen is that anaconda_architecture
(in plugins/python-build/share/python-build/anaconda-1.9.1) should return MacOSX-x86_64
; it returns Darwin-x86_64
instead.
I am trying to setup a virtualenv with --system-site-packages
to use compiled/pre-built packages, and noticed that e.g. ipython
fails to run with:
% pyenv virtualenv --system-site-packages 3.4.2 paperwork3
...
% ipython
pyenv: ipython: command not found
The `ipython' command exists in these Python versions:
...
Trying to install it skips it, because it appears to be installed already.
Could pyenv somehow handle this, especially after trying to (re-)install it?
I installed pyenv ealier and everything was working great. I installed python2.7.6 with pyenv as per the documentation and tested it - everything was working fine. Every time I went into the test2.7 folder and checked the python version everything seemed correct - python 2.7.6 was being used.
After installing the pyenv-virtualenv plugin, the system version of python is being used, not the one set with pyenv.
I did not make any changes to my .bash_profile after the initial installation of pyenv, so I'm not sure why this has stopped working.
test2.7 >> cat .python-version
2.7.6
test2.7 >> pyenv local
2.7.6
test2.7 >> python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Many tools need this variable install properly. For example jedi project. Also many users set their prompt with it. So it really necessary for us.
$ pyenv shell venv27-default
$ echo $VIRTUAL_ENV
$
What is the advantage of using this versus doing:
mkvirtualenv -p /path/to/pyenv/python/bin/python env
Greatly appreciate your response.
I've installed pyenv and pyenv-virtualenv. pyenv seems to be working great, and it appears I am able to create a virtualenv, but I can not seem to activate the virtualenv.
test3.3 >> pyenv virtualenvs
py276 (created from /Users/insomniac/.pyenv/versions/2.7.6)
py333 (created from /Users/insomniac/.pyenv/versions/3.3.3)
test3.3 >> pyenv activate py333
pyenv: no such command `activate'
How can I activate the virtual env? Also, is there a way to auto-activate and auto-deactivate the virtual environment when I go in and out of the directory?
Thanks,
C.
Hi,
I have been messing around with this for a few minutes and I can't quite figure out what the issue is. So I made a virtualenv to test out pyechonest
for my brother, and once I was done I went to delete the virtualenv. First I simply deleted the directory containing the virtualenv. I have done this in the past and it has worked fine.
Now I get spammed with the following messages every time I execute any command in the terminal:
pyenv: version `echonest2' is not installed
pyenv: version `echonest2' not installed
pyenv: version `echonest2' is not installed
echonest2 is the name of the virtualenv that I created.
I have also tried using pyenv uninstall echonest2
and that didn't seem to help either. The only way I can get these messages to stop showing up is to take the stuff related to pyenv
out of my .bashrc
. I have even tried completely uninstalling pyenv (by deleting the .pyenv
) directory, and that still didn't solve it.
Hopefully this makes sense.
Thanks!
P.S. I am running Arch Linux if that makes any difference.
Not sure if I did something wrong, but seems that the venv environment lacks of the pydoc link to the installed pyenv Python version, i.e, it's calling the system default instance from within the virtualenv, instead of the installed pyenv version it depends on.
Happened with pyenv + virtualenv of 3.4.2 python version:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.