8

I installed Python 3.5.2 using Anaconda 4.1.1 on the Windows Anniversary Edition Linux Subsystem (WSL), which is more or less embedded Ubuntu 14.04.5 LTS.

I installed virtualenv using:

pip install virtualenv

Then I tried to create a virtual environment inside ~/temp:

user@host:~$ virtualenv ~/temp/test
Using base prefix '/home/user/anaconda3'
New python executable in /home/user/temp/test/bin/python
/home/user/temp/test/bin/python: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable /home/user/temp/test/bin/python is not functioning
ERROR: It thinks sys.prefix is '/home/user' (should be '/home/user/temp/test')
ERROR: virtualenv is not compatible with this system or executable

It's easy to assume that this is just a WSL issue, but everything else was working so far, and I've seen similar errors reported on Ubuntu. Any idea what the problem is?

Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
  • I think you need to pass the `-p python3` option to tell `virtualenv` you want a Python 3 interpreter, i.e., try `virtualenv ~/temp/test -p python3` and see if that changes things. – edwinksl Sep 02 '16 at 20:05
  • Nope; adding `-p python3` changed nothing. – Garret Wilson Sep 02 '16 at 20:09
  • 1
    anaconda prefers you create environments with [conda](http://stackoverflow.com/a/38220776). also see [anaconda-issues](https://github.com/ContinuumIO/anaconda-issues/issues/305). – brennan Sep 06 '16 at 23:14
  • 1
    @bren, we all have our preferences, and you could even argue that conda is better than pip and I wouldn't disagree. But that's a separate issue. You didn't address the problem, and the link you gave does not address the problem either---even if it has comments in it arguing about which tool is better. The question is about what is causing an error with pip---not whether someone prefers something-besides-pip. – Garret Wilson Sep 07 '16 at 05:04
  • Meant to post [this issue](https://github.com/ContinuumIO/anaconda-issues/issues/1034) – brennan Sep 07 '16 at 05:18

2 Answers2

22

I have not experienced the same issue or tried to replicate the WSL environment. But usually when something similar happens with other libraries it is just likely to be a poorly configured environment. You have to checkout your library path:

echo $LD_LIBRARY_PATH

And make sure the directory that holds libpython is there. If not:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/the/py/lib/dir

Add this last line to your .bash_profile or .bashrc to make it permanent.

rll
  • 5,509
  • 3
  • 31
  • 46
  • 4
    That was it! I added `export LD_LIBRARY="$LD_LIBRARY_PATH:$HOME/anaconda3/lib"` to my `.bashrc` and now `virtualenv` works. Thank you very much! – Garret Wilson Sep 12 '16 at 17:52
2

mine solution :

open a shell

cd
vim .bashrc

add a line

export LD_LIBRARY_PATH=~/anaconda3/lib