This morning I wanted to create a virtualenv on Mac OS X where my default python is now anaconda, so I needed to install virtualenv:
$ conda install virtualenv
Fetching package metadata: ....
Solving package specifications: .
Package plan for installation in environment /Users/cwithers/anaconda:
The following packages will be downloaded:
package | build
---------------------------|-----------------
conda-env-2.2.1 | py27_0 21 KB
python-2.7.10 | 0 11.4 MB
requests-2.7.0 | py27_0 594 KB
setuptools-17.0 | py27_0 341 KB
conda-3.13.0 | py27_0 168 KB
pip-7.0.3 | py27_0 1.4 MB
virtualenv-13.0.1 | py27_0 1.6 MB
------------------------------------------------------------
Total: 15.5 MB
The following NEW packages will be INSTALLED:
virtualenv: 13.0.1-py27_0
The following packages will be UPDATED:
conda: 3.11.0-py27_0 --> 3.13.0-py27_0
conda-env: 2.1.4-py27_0 --> 2.2.1-py27_0
pip: 6.1.1-py27_0 --> 7.0.3-py27_0
python: 2.7.9-1 --> 2.7.10-0
requests: 2.6.2-py27_0 --> 2.7.0-py27_0
setuptools: 15.1-py27_1 --> 17.0-py27_0
However, now when I try to create the env I get this error:
$ virtualenv ve
New python executable in ve/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/cwithers/vcs/x/ve/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/cwithers/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
File "/Users/cwithers/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
File "/Users/cwithers/anaconda/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/Users/cwithers/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/cwithers/vcs/x/ve/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/cwithers/vcs/x/ve/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
Downgrading to Python 2.7.9-1 made this problem go away.
It looks like I'm not the only one experiencing this:
I can reproduce this. @ilanschnell we should probably see if we can fix this before the release.
This is probably the same problem:
http://stackoverflow.com/questions/30812290/tox-conda-travis-ci-raises-importerror-pyerr-replaceexception
I am experiencing a similar error with conda after installing mayavi 4.3 from a fresh Anaconda 2.2 installation on Mac OsX yosemite. It might be because of the upgrade from python 2.7.9 to 2.7.10.
German:conda-recipes-master predout$ conda install mayavi=4.3.0
Fetching package metadata: ....
Solving package specifications: ...............
Package plan for installation in environment /Users/predout/anaconda:
The following packages will be downloaded:
package | build
---------------------------|-----------------
qt-4.8.6 | 3 39.0 MB
numpy-1.7.1 | py27_2 2.8 MB
python-2.7.10 | 0 11.4 MB
shiboken-1.1.2 | py27_0 875 KB
traits-4.4.0 | py27_0 374 KB
vtk-5.10.1 | py27_0 28.8 MB
pyface-4.4.0 | py27_0 693 KB
pyside-1.1.2 | py27_1 5.2 MB
traitsui-4.4.0 | py27_0 837 KB
apptools-4.2.0 | py27_1 271 KB
envisage-4.4.0 | py27_0 266 KB
mayavi-4.3.0 | np17py27_4 10.0 MB
------------------------------------------------------------
Total: 100.3 MB
The following NEW packages will be INSTALLED:
apptools: 4.2.0-py27_1
envisage: 4.4.0-py27_0
mayavi: 4.3.0-np17py27_4
pyface: 4.4.0-py27_0
pyside: 1.1.2-py27_1
shiboken: 1.1.2-py27_0
traits: 4.4.0-py27_0
traitsui: 4.4.0-py27_0
vtk: 5.10.1-py27_0
The following packages will be UPDATED:
freetype: 2.5.2-0 --> 2.5.2-2
libpng: 1.5.13-1 --> 1.6.17-0
python: 2.7.9-1 --> 2.7.10-0
qt: 4.8.6-0 --> 4.8.6-3
The following packages will be DOWNGRADED:
numpy: 1.9.2-py27_0 --> 1.7.1-py27_2
Proceed ([y]/n)? y
Fetching packages ...
qt-4.8.6-3.tar 100% |#######################################################################| Time: 0:00:04 8.33 MB/s
numpy-1.7.1-py 100% |#######################################################################| Time: 0:00:00 4.45 MB/s
python-2.7.10- 100% |#######################################################################| Time: 0:00:02 5.79 MB/s
shiboken-1.1.2 100% |#######################################################################| Time: 0:00:00 3.17 MB/s
traits-4.4.0-p 100% |#######################################################################| Time: 0:00:00 1.52 MB/s
vtk-5.10.1-py2 100% |#######################################################################| Time: 0:00:03 9.53 MB/s
pyface-4.4.0-p 100% |#######################################################################| Time: 0:00:00 2.25 MB/s
pyside-1.1.2-p 100% |#######################################################################| Time: 0:00:01 5.09 MB/s
traitsui-4.4.0 100% |#######################################################################| Time: 0:00:00 2.99 MB/s
apptools-4.2.0 100% |#######################################################################| Time: 0:00:00 1.59 MB/s
envisage-4.4.0 100% |#######################################################################| Time: 0:00:00 1.51 MB/s
mayavi-4.3.0-n 100% |#######################################################################| Time: 0:00:01 8.59 MB/s
Extracting packages ...
[ ]| [ COMPLETE ]|##########################################################################################| 100%
Unlinking packages ...
[ COMPLETE ]|##########################################################################################| 100%
Linking packages ...
[ COMPLETE ]|##########################################################################################| 100%
And after when trying to use conda again:
German:conda-recipes-master predout$ conda
Traceback (most recent call last):
File "/Users/predout/anaconda/bin/conda", line 5, in <module>
sys.exit(main())
File "/Users/predout/anaconda/lib/python2.7/site-packages/conda/cli/main.py", line 106, in main
from conda.cli import conda_argparse
File "/Users/predout/anaconda/lib/python2.7/site-packages/conda/cli/conda_argparse.py", line 15, in <module>
from conda.cli import common
File "/Users/predout/anaconda/lib/python2.7/site-packages/conda/cli/common.py", line 13, in <module>
import conda.config as config
File "/Users/predout/anaconda/lib/python2.7/site-packages/conda/config.py", line 16, in <module>
from conda.compat import urlparse
File "/Users/predout/anaconda/lib/python2.7/site-packages/conda/compat.py", line 64, in <module>
from pipes import quote
File "/Users/predout/anaconda/lib/python2.7/pipes.py", line 62, in <module>
import tempfile
File "/Users/predout/anaconda/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/Users/predout/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/predout/anaconda/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/predout/anaconda/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
Importing _io works fine for me (on OSX 10.7, and Python 2.7.10). It is not clear to me where the problem lies, i.e. whether this is a build problem or an upstream problem. Nothing has really changed with respect to the Python 2.7.10 update in how we build Python.
It works for me too, except when trying to create a virtualenv. I'm not sure what causes it, since the virtualenv seems to just put a symlink to the lib-dynload.
If anyone is seeing this problem and is linked here from stack overflow, I worked around it by moving back to Python 2.7.9:
conda install python=2.7.9
Which is the exact Python version you use? I still get the same error with:
conda: 3.14.1-py27_0
conda-env: 2.2.3-py27_0
pip: 7.0.3-py27_0
python: 2.7.9-3
setuptools: 17.1.1-py27_0
I see the same problem on linux, and the python=2.7.9 workaround does not work for me (I get python2.7/lib-dynload/_io.so: undefined symbol: _PyLong_AsInt).
As expected, there is some unholy business with my system and anaconda python executables:
ldd ~/anaconda/env/bin/python
[...]
libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0
ldd ~/anaconda/bin/python
[..]
libpython2.7.so.1.0 => ~/anaconda/bin/../lib/libpython2.7.so.1.0
@kyleabeauchamp - it sounds like you have a separate issue, so please log it separately. This one is specifically for "Symbol not found: __PyErr_ReplaceException" on Mac OS X when using Python 2.7.10-0
I think I was a bit unclear. I saw exactly the same error (__PyErr_ReplaceException) on linux with py2.7.10.
The other error message I reported was only observed when I attempted the workaround (py2.7.9) described above.
Any progress on this?
I'm on OSX, and can confirm the conda install python=2.7.9 downgrade "fixes" the issue.
A couple of months on, any news on when a fix will land @ilanschnell?
I had python 2.7.10 on conda, and started experiencing this issue when I added /System/Library/Frameworks/Python.framework/Versions/2.7/lib to the DYLD_LIBRARY_PATH environment variable.
Downgrading worked for me too.
Downgrading fixed the problem for me as well.
Downgrading also fixed this problem for me (I actually didn't notice this problem until it kept vim pymode from reporting any linter errors. go figure.)
I ran the "conda install python=2.7.9", it says it installed ok. But when I do "python --version" I still see 2.7.10.
What else I should do?
This is probably a condo/virtualenv co-issue.
I have the same problems with Python 2.7.11 and Python 3.5.1 and condo 3.18.9, pip 7.1.2, virtualenv 13.1.2. With Python 3.5.1, virtual environment creation fails with "virtualenv" and "pyvenv" (with a slightly different error).
Note that virtualenv/pyvenv is not my primary use case. I could easily use conda-environments for that. But I need to use tox which uses virtualenv.
Known, unresolved, issue for 6+ months?!?! That's pretty disappointing.
I ran into this after downgrading from 2.7.11 to 2.7.10, as recommended, due to _another_ virtualenv / conda issue. Can't conda learn to play with others?
Downgrading (again) from python 2.7.10 to 2.7.9 worked for me on OS X. The original 2.7.11 error was:
$ virtualenv .
New python executable in ./bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/tfmorris/git/git-lit/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/tfmorris/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
File "/Users/tfmorris/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
File "/Users/tfmorris/anaconda/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/Users/tfmorris/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/tfmorris/git/git-lit/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /Users/tfmorris/git/git-lit/lib/python2.7/lib-dynload/_io.so
I just ran into this issue. In my case, the problem seems originate from having the DYLD_LIBRARY_PATH environment variable set; unsetting this environment variable fixes the issue.
I didn't spend too much time debugging the issue, so I'm not 100% sure which dynamic library is actually the problem, but it seems like having DYLD_LIBRARY_PATH set causes the conda python interpreter to mistakenly load a dynamic library from outside its install directory.
Setting these environment variables is never a good idea, unless you're trying to debug some wired linking problem. Any program will potentially change it's behavior (or break) when you set DYLD_LIBRARY_PATH, not just the Python we bundle in Anaconda.
I don't know how else, for example, to dynamically link against the MATLAB-Python bridge:
http://www.mathworks.com/matlabcentral/answers/180518-why-does-matlab-engine-for-python-crash-when-using-a-non-system-default-version-of-python-on-mac
Downgrading fixed the problem for me as well. But I want to use Python 2.7.11
Another error is python version in virtual env:
tu@mac ~/workspace $ mkvirtualenv dj17
New python executable in /Users/tu/.virtualenvs/dj17/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/tu/.virtualenvs/dj17/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/tu/.virtualenvs/dj17/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/tu/.virtualenvs/dj17/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/tu/.virtualenvs/dj17/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/tu/.virtualenvs/dj17/bin/get_env_details
Error: deactivate must be sourced. Run 'source deactivate'
instead of 'deactivate'.
Usage: source deactivate
removes the 'bin' directory of the environment activated with 'source
activate' from PATH.
(dj17) tu@mac ~/workspace $ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
(dj17) tu@mac ~/workspace $ deactivate
tu@mac ~/workspace $ python
Python 2.7.9 |Anaconda 2.5.0 (x86_64)| (default, Dec 15 2014, 10:37:34)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>>
tu@mac ~/workspace $ which virtualenv
/Users/tu/anaconda2/bin/virtualenv
tu@mac ~/workspace $ which python
/Users/tu/anaconda2/bin/python
tu@mac ~/workspace $ python -V
Python 2.7.9 :: Anaconda 2.5.0 (x86_64)
tu@mac ~/workspace $ workon dj17
Error: deactivate must be sourced. Run 'source deactivate'
instead of 'deactivate'.
Usage: source deactivate
removes the 'bin' directory of the environment activated with 'source
activate' from PATH.
(dj17) tu@mac ~/workspace $ python -V
Python 2.7.10
downgrade python version to 2.7.9. Its working for me on OSX.
Downgrading python to 2.7.9 not working on OSX yosemite
PFB logs
New python executable in analysis_python3/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/xxxx/Docume...s_python3/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "
File "//anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/init.py", line 13, in
File "//anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/utils/init.py", line 15, in
File "//anaconda/lib/python2.7/zipfile.py", line 6, in
import io
File "//anaconda/lib/python2.7/io.py", line 51, in
import _io
ImportError: dlopen(/Users/xxxx/Documents/envs/analysis_python3/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /Users/xxxx/Documents/envs/analysis_python3/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "//anaconda/bin/virtualenv", line 11, in
sys.exit(main())
File "//anaconda/lib/python2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "//anaconda/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "//anaconda/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "//anaconda/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/xxx/Docume...s_python3/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
The issue here is a current incompatibility between virtualenv and conda. You can temporarily set DYLD_LIBRARY_PATH, but doing so will very likely create issues for other software you run in that same environment. While it's a hard problem with lots of gotcha, we need a solution to make conda envs play nice with virutalenvs.
Futzing with DYLD_LIBRARY_PATH will lead to much more trouble, so I'd avoid.
Agreed on the virtualenv vs conda front, it's a shame none of the conda maintainers seem interested...
@cjw296 I'm definitely interested.
I'm going to close this issue for now because it's a fundamental issue with simultaneously using conda and virutalenv. I'm definitely interested in tackling that core issue at some point though. Would also welcome a technical outline on potential solutions.
Wow, you're "definitely interested" but effectively close the issue as "won't fix"?
Please can you re-open this issue and use it as a reminder that there are a growing number of people who are stuck on Python 2.7.9 when using conda, because upgrading any further breaks their virtualenv usage?
:+1: to @cjw296's suggestion
Alternatively, tackle #1277 so I can use a standard pip requirements.txt file with conda environments.
@pjbull - how does that help when a package isn't available in the conda repos?
Just bumped into this issue...any updates?
For now I'm using this workaround:
$ conda install virtualenv
Fetching package metadata: ....
Solving package specifications: ..................
Package plan for installation in environment /Users/jessep/anaconda:
The following packages will be downloaded:
package | build
---------------------------|-----------------
openssl-1.0.2g | 0 3.0 MB
python-2.7.10 | 2 9.9 MB
setuptools-20.2.2 | py27_0 453 KB
conda-4.0.1 | py27_0 184 KB
pip-8.1.0 | py27_0 1.5 MB
virtualenv-13.0.1 | py27_0 1.6 MB
------------------------------------------------------------
Total: 16.6 MB
The following NEW packages will be INSTALLED:
virtualenv: 13.0.1-py27_0
The following packages will be UPDATED:
conda: 3.19.3-py27_0 --> 4.0.1-py27_0
openssl: 1.0.2f-0 --> 1.0.2g-0
pip: 8.0.3-py27_0 --> 8.1.0-py27_0
setuptools: 20.1.1-py27_0 --> 20.2.2-py27_0
The following packages will be DOWNGRADED:
python: 2.7.11-0 --> 2.7.10-2
Proceed ([y]/n)? y
Fetching packages ...
openssl-1.0.2g 100% |##########################################################################################| Time: 0:00:02 1.41 MB/s
python-2.7.10- 100% |##########################################################################################| Time: 0:00:07 1.39 MB/s
setuptools-20. 100% |##########################################################################################| Time: 0:00:00 987.20 kB/s
conda-4.0.1-py 100% |##########################################################################################| Time: 0:00:00 659.16 kB/s
pip-8.1.0-py27 100% |##########################################################################################| Time: 0:00:00 1.67 MB/s
virtualenv-13. 100% |##########################################################################################| Time: 0:00:01 1.24 MB/s
Extracting packages ...
[ COMPLETE ]|#############################################################################################################| 100%
Unlinking packages ...
[ COMPLETE ]|#############################################################################################################| 100%
Linking packages ...
[ COMPLETE ]|#############################################################################################################| 100%
$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip, wheel...done.
@cjw296 yep, it only helps if conda environments can actually replace virtualenvs (i.e., fallback to install packages from pip).
I should have used virtualenv venv --no-setuptools --no-pip --no-wheel while creating my virtual environment as anaconda is messing with my default python setup. Ref: http://stackoverflow.com/questions/35153565/virtualenv-error-while-setting-up-django-in-azure-cloud-platform-on-mac
Oh well I am done with Anaconda, thanks much. Uninstalling and starting over with clean slate. Lot of work :(
I just was forced into downgrading to 2.7.9 by this issue as well. I would greatly appreciate it if this issue could be reopened.
@adw, @cjw296, and/or anybody else who has run into thus recently...
What is the output of /usr/bin/python -V?
@cjw296 I didn't intend to indicate "won't fix" when I closed the issue. Just didn't intend to track progress on the larger and more general problem with this ticket. But I understand the frustration. We'll keep it open.
For background, here's the issue as it stands for virtualenv right now...
Let's say I have conda installed at /conda and so my python executable indicated by which python is at /conda/bin/python. That means the shared library that python runs against at startup/load time is /conda/lib/libpython2.7.dylib. Actually, it links against ../lib/libpython2.7.dylib. That is, the link path is relative.
Say I delete that file though... The OS X system loader has a library search path similar to the executable path PATH. By default on OS X, this library search path is $HOME/lib:/usr/local/lib:/lib:/usr/lib (see man dyld). So, when I delete /conda/lib/libpython2.7.dylib, then when /conda/bin/python runs, the loader will end up finding a libpython2.7.dylib at /usr/lib/libpython2.7.dylib. The problem is, that library is compiled for the _system_ python at /usr/bin/python, and thus we get that symbol error.
Now let's look at virtualenv. Say I'm working on myproject located at ~/projects/myproject, and in that directoryI create a virtualenv with virtualenv ve --python=/conda/bin/python2.7. Now after source ~/projects/myproject/ve/bin/activate, which python shows ~/projects/myproject/ve/bin/python. What dynamic library is that python going to load against? Well, it would be ../lib/libpython2.7.dylib or ~/projects/myproject/ve/lib/libpython2.7.dylib. Except that file doesn't exist. (In fact, ~/projects/myproject/ve/lib/ will probably be completely empty.) So the loader falls back to the library search path and finds /usr/lib/libpython2.7.dylib.
:boom: Symbol error.
So, there _is_ a way to hack this right now until we come up with a legitimate solution... Immediately after you create the empty virtualenv,
rmdir ~/projects/myproject/ve/lib && ln -s /conda/lib ~/projects/myproject/ve/lib
Now you should no longer have the symbol error. Except... the next logical thing will be to want to use tox. Tox uses virtualenv to create virtual environments by default in ~/projects/myproject/.tox. So we run into the exact same issue all over again and back to square 1.
@cjw296 and everybody else, was this at least a little helpful just to give some context?
Another solution would be to just use python3 :stuck_out_tongue_closed_eyes:.
@kalefranz:
$ /usr/bin/python -V
Python 2.7.10
The context is, indeed, very helpful, and feels a lot like the pain that every psycopg2 user on a Mac has:
https://github.com/psycopg/psycopg2/issues/385
https://github.com/alekstorm/backports.ssl/issues/9
I can't help but wonder why relative link paths would ever be a good idea? Is that a Python thing or a Mac thing?
@kalefranz - how would Python 3 help? Not that it's an acceptable solution, as I'm sure you appreciate...
@kalefranz thanks for the explanation. Why does downgrading Python versions fix the issue, though?
Because that's the version that matches the OS X system python at /usr/bin/python.
On Apr 20, 2016, at 12:27 PM, Scotty Nelson [email protected] wrote:
@kalefranz thanks for the explanation. Why does downgrading Python versions fix the issue, though?
โ
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
In his comment above, @kalefranz described the problem well, but I don't think removing my-virtual-env/lib and replacing it with a symlink to conda/lib is a great solution. Any packages you install to your "virtual" env will actually be installed into your "real" python interpreter (the one from conda).
Here's an alternative option: It turns out you can _pre-emptively_ create the virtual environment (as an empty directory), and then symlink the missing file _before_ running virtualenv (libpython2.7.dylib). Then virtualenv works as expected.
In other words:
$ mkdir -p ve/lib
$ cd ve/lib && ln -s /path/to/miniconda/lib/libpython2.7.dylib && cd -
$ virtualenv ve
Here's a quick-and-dirty script that does this. Use it as if it were the virtualenv command. (Caveat: This simple script misses a few corner cases, like --help, but you get the idea. I haven't tested this in depth, but it seems to work.)
#!/bin/bash
# conda-virtualenv.sh
# Usage: Just like virtualenv
# Locate libpython (e.g. libpython2.7.so)
ORIG_PREFIX=$(python -c "import sys; sys.stdout.write(sys.exec_prefix)")
PYVER=$(python -c "import sys; sys.stdout.write('.'.join(map(str, sys.version_info[:2])))")
LIBPYTHON=$(ls ${ORIG_PREFIX}/lib/libpython${PYVER}*)
# Get the last arg, which is the name
# of the new virtual env directory.
for VENV_DIR; do true; done
# Pre-emptively create the env directory,
# and symlink lib/libpython2.7.so into it.
mkdir -p $VENV_DIR/lib
cd $VENV_DIR/lib && ln -s ${LIBPYTHON} && cd -
# Now call virtualenv with the user's args
virtualenv "$@"
I ran into the same issue. Using --python /usr/bin/python worked for me. Here is an example.
virtualenv -p /usr/bin/python /tmp/eb_python_app
Try this method
virtualenv -p /usr/bin/python2.7
http://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv
Unless I'm missing something, the virtualenv -p /usr/bin/python method is not correct. The whole point of this discussion is to figure out how to get virtualenv working with the python interpreter that conda installed. By using virtualenv -p, you are forcing it to use a different python interpreter.
Is there any benefit to installing virtualenv with conda and then using the system python interpreter? (Personally, I don't have much experience with virtualenv, so I could be confused. But it seems wrong to do that.)
@stuarteberg
In general, you can create different virtual environment with different version of python use virtualenv in your computer.
you need to add the version of python and the path where you want to create, just like this:


Hello, I'm new to this thread (and Python) but am having an issue with the virtual environment i installed conda into last night. I've got two virtual environments, one for python2 and one for python3. I've installed conda into my python3 ve, but when I try and switch to that ve i get the following error:
Chriss-MacBook-Pro:~ chris.larkin_bit$ workon py3_base
-bash: virtualenv_deactivate: command not found
could not find environment: py3_base
If useful, this is also the result from running lsvirtualenv:
Chriss-MacBook-Pro:~ chris.larkin_bit$ lsvirtualenv
py2_base
========
py3_base
========
Error: did not expect more than one argument.
(Got showvirtualenv )
showvirtualenv [env]
After some digging around on github it seems that conda is conflicting with my ve somehow. I'm probably missing something quite simple, so do shout if there's an easy fix. I had a careful look through the files I downloaded with Conda, and removed the conda.exec file in my ve folder (i've replaced it again now) and I then get the following error when I type workon py3_base:
Chriss-MacBook-Pro:~ chris.larkin_bit$ workon py3_base
-bash: virtualenv_deactivate: command not found
-bash: /Users/chris.larkin_bit/.virtualenvs/py3_base/bin/conda: No such file or directory
I'd be really happy to just uninstall Conda and everything I've installed in the past 24 hours and get back to my ordinary ve. Or if anyone can help with other suggestions, i'd be very grateful.
@h8d5lo1 - use either virtualenv or conda, don't try and use both at the same time. My recommendation would be to start with virtualenv and pip.
Please note: this is an issue tracker for a specific bug, not a mailing list. You are not experiencing that bug.
@cjw296 Thanks for your comments, and forgive my tardy reply. Using conda within my virtualenv caused a few problems that I wasn't able to resolve, and I resorted to restoring factory settings on my machine and reinstalling all software virtualenvs from scratch. It's all sorted now though and I have everything I need up and running - I also learned a fair bit about the back end of package management in conda and virtualenvs!
And apologies for posting an inappropriate message. I'm quite new to github so am still learning the etiquette.
Cheers
september 2016 here, still having to downgrade to 2.7.9, that does fix it but boy should some one fix setuptools
October 2016. I was trying to get jedi-vim to work on my new Mac (OS X Sierra) and I was getting the message "Please install Jedi if you want to use jedi-vim." when I already had Jedi on the version of Python my Vim was using (which was the miniconda one). Calling conda install python=2.7.9 (ie: downgrading from python 2.7.10 to 2.7.9) fixed the error message.
Thanks all for the details, especially @kalefranz. Just to underscore what was suggested above, the solution is not to downgrade specifically to python 2.7.9 but to downgrade _conda_ to whatever version is the _system_ version. Today (on OS X 10.11.6) I downgraded from 2.7.12 to 2.7.10 and solved the same problem.
macOS, downgrade python version to 2.7.9. Its working for me too.
conda install python=2.7.9
as of nov 2016 downgrading to python 2.7.9 is the best solution :(
mac os x 10.9.5 with /usr/bin/python version 2.7.5, conda one version 2.7.13, same Symbol not found: __PyCodecInfo_GetIncrementalDecoder error as in https://github.com/conda/conda/issues/1367#issuecomment-174357848, downgrading to python 2.7.9 fixes it for me too.
Actually the python installed by virtualenv is the one in /usr/bin (2.7.5), despite trying also with -p option and a path pointing to the conda Python 2.7.9.
$ virtualenv -p /opt/miniconda3/envs/py27/bin/python venv2
Already using interpreter /opt/miniconda3/envs/py27/bin/python
New python executable in /Users/xxx/path/venv2/bin/python
Installing setuptools, pip, wheel...done.
$ which -a python
/Users/xxx/path/venv2/bin/python
/opt/miniconda3/envs/py27/bin/python
/opt/miniconda3/bin/python
/usr/bin/python
(venv2)
$ /opt/miniconda3/envs/py27/bin/python --version
Python 2.7.9 :: Continuum Analytics, Inc.
(venv2)
$ /usr/bin/python --version
Python 2.7.5
(venv2)
$ python --version
Python 2.7.5
(venv2)
edit: method described at https://github.com/conda/conda/issues/1367#issuecomment-217958169 by @stuarteberg worked for me to get Python 2.7.9 and not the system one in my virtualenv. (thanks @stuarteberg ...) and in fact then I can use Python version of my choice.
edited to mention that the new virtualenv mentioned at https://github.com/conda/conda/issues/1367#issuecomment-278838877 fixes it for me on mac os x 10.9.5, using either Python 2.7.13 or 3.5.2 from conda.
February 2017, and still no solution not involving untested hacks.
I confirm that the downgrade to Python 2.7.9 worked in my case.
While it's buried above, here's a cross-link reference: https://github.com/conda-forge/staged-recipes/issues/1139
There's not much conda can do to fix this. The problem is really structural with virtualenv. I'm not sure if anyone has yet filed an issue on the virtualenv tracker or not.
@mingwandroid Has just released into repo.continuum.io a patched virtualenv package that fixes this issue. You must conda install virtualenv (or conda update); the version you get from pip install virtualenv will not work. This was quite the heroic piece of engineering work. Thanks @mingwandroid ๐
That's great news. Thanks s @mingwandroid and thanks Kale for letting me know.
Great news indeed! ๐๐๐ @mingwandroid
No problem everyone. Personally, I much prefer conda envs to virtualenvs, but I wanted to fix this one because it seems to be important to your workflows.
Tangential: @mingwandroid - how do you ensure repeatable builds of your conda environments? environment.yml or something else?
Mostly I use a single root env. Conda-build creates the other envs that I frequently use (build and test ones) since I spend most of my time building conda packages rather than doing general computing, Python or data science work.
But if I do need reproducibility, I use conda list -n <env> -e
I am on OS Sierra(10.12) and downgrading fixed the issue for me.
downgrade code via @pjbull : conda install python=2.7.9
@brlrb - can you try doing a conda update virtualenv and then creating a new virtualenv? @mingwandroid has fixed the real problem here!
I'm on OS Sierra and downgrading also fixed this issue for me.
@marchofreason, this core problem here is fixed so I do not understand why you needed to downgrade. You should instead install the latest conda virtualenv package and everything should work just fine.
If it does not I would appreciate exact reproduction steps. Here are mine:
Python 3:
pushd /tmp
curl -SLO https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh -b -p /tmp/mc3
source /tmp/mc3/bin/activate
conda install -y virtualenv
mkdir -p /tmp/venv/venv
virtualenv -p $(which python) /tmp/venv/venv/my_project
/tmp/venv/venv/my_project/bin/python -c 'import sys; print(sys.prefix); print(sys.version)'
final line outputs:
/tmp/venv/venv/my_project
3.6.1 |Continuum Analytics, Inc.| (default, Mar 22 2017, 19:25:17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)
Python 2:
source deactivate
rm -rf /tmp/venv
curl -SLO https://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh
bash Miniconda2-latest-MacOSX-x86_64.sh -b -p /tmp/mc2
source /tmp/mc2/bin/activate
conda install -y virtualenv
mkdir -p /tmp/venv/venv
virtualenv -p $(which python) /tmp/venv/venv/my_project
/tmp/venv/venv/my_project/bin/python -c 'import sys; print(sys.prefix); print(sys.version)'
final line outputs:
/tmp/venv/venv/my_project
2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
wow... yeah, macOS 10.12, downgrade also fixed it for me.
@jbmaxwell - @mingwandroid fixed this problem, no need to downgrade. Please see comments above... There's a reason this issue is closed!
Works for me too
Most helpful comment
If anyone is seeing this problem and is linked here from stack overflow, I worked around it by moving back to Python 2.7.9:
conda install python=2.7.9