Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 2.7.10-0 fails to create virtualenv with Symbol not found: __PyErr_ReplaceException #1367

Closed
cjw296 opened this issue Jun 9, 2015 · 76 comments
Labels
locked [bot] locked due to inactivity

Comments

@cjw296
Copy link

cjw296 commented Jun 9, 2015

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:

http://stackoverflow.com/questions/30674338/upgrade-to-python-2-7-10-target-wsgi-script-cannot-be-loaded-as-python-module

@asmeurer
Copy link
Contributor

I can reproduce this. @ilanschnell we should probably see if we can fix this before the release.

@ntfrgl
Copy link

ntfrgl commented Jun 22, 2015

@ggonzale
Copy link

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

@ilanschnell
Copy link
Contributor

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.

@asmeurer
Copy link
Contributor

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.

@pjbull
Copy link

pjbull commented Jul 5, 2015

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

@ntfrgl
Copy link

ntfrgl commented Jul 6, 2015

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

@kyleabeauchamp
Copy link

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).

@kyleabeauchamp
Copy link

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

@cjw296
Copy link
Author

cjw296 commented Jul 7, 2015

@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

@kyleabeauchamp
Copy link

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.

@ntfrgl
Copy link

ntfrgl commented Jul 30, 2015

Any progress on this?

@kalefranz
Copy link
Contributor

I'm on OSX, and can confirm the conda install python=2.7.9 downgrade "fixes" the issue.

@cjw296
Copy link
Author

cjw296 commented Aug 12, 2015

A couple of months on, any news on when a fix will land @ilanschnell?

@goretkin
Copy link

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.

@burkesquires
Copy link

Downgrading fixed the problem for me as well.

@katyhuff
Copy link

katyhuff commented Sep 3, 2015

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.)

@FranGhelfi
Copy link

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?

@jenisys
Copy link

jenisys commented Dec 21, 2015

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.

@tfmorris
Copy link

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

@chenghlee
Copy link
Contributor

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.

@ilanschnell
Copy link
Contributor

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.

@goretkin
Copy link

goretkin commented Feb 9, 2016

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

@twz915
Copy link

twz915 commented Feb 17, 2016

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

@agirwalkar
Copy link

downgrade python version to 2.7.9. Its working for me on OSX.

@vijayendra-g
Copy link

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 "", line 1, in
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

@is55555
Copy link

is55555 commented Feb 3, 2017

February 2017, and still no solution not involving untested hacks.

@alexcombessie
Copy link

I confirm that the downgrade to Python 2.7.9 worked in my case.

@kalefranz
Copy link
Contributor

While it's buried above, here's a cross-link reference: conda-forge/staged-recipes#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.

@kalefranz
Copy link
Contributor

@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 👏

@is55555
Copy link

is55555 commented Feb 10, 2017

That's great news. Thanks s @mingwandroid and thanks Kale for letting me know.

@dakl
Copy link

dakl commented Feb 12, 2017

Great news indeed! 🎉🎉🎉 @mingwandroid

@mingwandroid
Copy link
Contributor

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.

@cjw296
Copy link
Author

cjw296 commented Feb 12, 2017

Tangential: @mingwandroid - how do you ensure repeatable builds of your conda environments? environment.yml or something else?

@mingwandroid
Copy link
Contributor

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.

@mingwandroid
Copy link
Contributor

But if I do need reproducibility, I use conda list -n <env> -e

@brlrb
Copy link

brlrb commented Mar 11, 2017

I am on OS Sierra(10.12) and downgrading fixed the issue for me.

downgrade code via @pjbull : conda install python=2.7.9

@cjw296
Copy link
Author

cjw296 commented Mar 12, 2017

@brlrb - can you try doing a conda update virtualenv and then creating a new virtualenv? @mingwandroid has fixed the real problem here!

@markojak
Copy link

I'm on OS Sierra and downgrading also fixed this issue for me.

@mingwandroid
Copy link
Contributor

mingwandroid commented Apr 24, 2017

@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)]

@jbmaxwell
Copy link

wow... yeah, macOS 10.12, downgrade also fixed it for me.

@cjw296
Copy link
Author

cjw296 commented Aug 1, 2017

@jbmaxwell - @mingwandroid fixed this problem, no need to downgrade. Please see comments above... There's a reason this issue is closed!

@xuy2
Copy link

xuy2 commented Jun 21, 2018

Works for me too

@github-actions
Copy link

Hi there, thank you for your contribution to Conda!

This issue has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

No branches or pull requests