Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

assert error when installing virtualenv with different python

My server has Python2.5 I wanna be jump to newest Python (2.7.x in my case). I compiled python from source, I downloaded newest virtualenv (1.5.1).

Now basically what im trying to do:

./packages/virtualenv/virtualenv.py --python=packages/Python-2.7/python env/

Typing:

./packages/virtualenv/virtualenv.py

Provides:

1.5.1

While Typing:

packages/Python-2.7/python

Provides:

Python 2.7 (r27:82500, Nov 21 2010, 23:19:15) 
[GCC 4.3.2] on linux2
(cut help mesage)
>>>

However runing virutalenv results in:

AssertionError: Filename /packages/Python-2.7/Lib/os.py does not start with any of these prefixes: ['/usr/local']

Whatever it means and whatever I am or I am not doing wrong.

P.S. While building env + python I based at question: How do I work around this problem creating a virtualenv environment with a custom-build Python?

like image 829
Drachenfels Avatar asked Sep 11 '25 07:09

Drachenfels


2 Answers

After reading and messing with this.

I found that this error might be related with lack of --prefix while runing ./configure for python. So I've run ./configure --prefix=/Path/To/Where/I/Want/Python/After/Compilation/ (in my case $HOME/packages/Python-2.7), then I've typed make, then make install (without using sudo - so python was safely put into where I told it to be as current user not root). After that virtualenv initiation did not crash with AssertionError and everything worked like a charm.

Hope that this question answered by author will eventually help someone. :)

like image 141
Drachenfels Avatar answered Sep 12 '25 22:09

Drachenfels


I don't have enough rep to add this as a comment and this question is 3 years old, but this might be useful to someone. In Windows, you have to path out to python.exe, but it seems that in Linux/OS X you just path to the folder. Example:

Windows:

virtualenv -p <PATH TO PYTHON.EXE> venv

Creates a virtual environment in subfolder "venv" in current directory.

like image 45
Mike Davlantes Avatar answered Sep 12 '25 20:09

Mike Davlantes