使用不同的 python 安装 virtualenv 时断言错误
我的服务器有Python2.5,我想跳转到最新的Python(在我的例子中是2.7.x)。我从源代码编译了 python,下载了最新的 virtualenv (1.5.1)。
现在基本上我想做的是:
./packages/virtualenv/virtualenv.py --python=packages/Python-2.7/python env/
键入:
./packages/virtualenv/virtualenv.py
提供:
1.5.1
键入时:
packages/Python-2.7/python
提供:
Python 2.7 (r27:82500, Nov 21 2010, 23:19:15)
[GCC 4.3.2] on linux2
(cut help mesage)
>>>
但是运行 virutalenv 会导致:
AssertionError: Filename /packages/Python-2.7/Lib/os.py 不以任何这些前缀开头:['/ usr/local']
无论这意味着什么,无论我是什么,或者我没有做错。
聚苯乙烯 在构建 env + python 时,我基于问题: 如何使用自定义构建的 Python 创建 virtualenv 环境来解决此问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
阅读并弄乱 这个。
我发现这个错误可能与运行 python 的
./configure
时缺少--prefix
有关。所以我运行了./configure --prefix=/Path/To/Where/I/Want/Python/After/Compilation/
(在我的例子中$HOME/packages/Python- 2.7
),然后我输入了make
,然后make install
(不使用sudo
- 所以 python 被安全地放入其中我告诉它是当前用户而不是 root )。之后 virtualenv 启动并没有因AssertionError
崩溃,一切都顺利进行。希望作者回答的这个问题最终能帮助别人。 :)
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 typedmake
, thenmake install
(without usingsudo
- so python was safely put into where I told it to be as current user not root). After that virtualenv initiation did not crash withAssertionError
and everything worked like a charm.Hope that this question answered by author will eventually help someone. :)
我没有足够的代表将其添加为评论,并且这个问题已有 3 年历史,但这可能对某人有用。在 Windows 中,您必须找到 python.exe 的路径,但似乎在 Linux/OS X 中您只需路径到该文件夹。示例:
Windows:
在当前目录的子文件夹“venv”中创建虚拟环境。
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:
Creates a virtual environment in subfolder "venv" in current directory.
我没有足够的代表来添加评论。 迈克的回答拯救了我。我正在使用窗户。
我收到错误:
我必须运行它 -
还需要从以管理员身份打开的 cmd 运行它。否则会收到错误
有人有足够的代表发表评论,请将其添加到 Mike 的 答案中作为评论。然后我会清除我的。
I don't have enough rep to add comment. Mike's answer save my day. I'm using windows.
I was getting the error :
I had to run this-
also need to run this from a cmd opened as Administrator. Otherwise getting the error
Someone with enough reps to comment please add this to Mike's answer as a comment. I'll then clear mine.