简体   繁体   English

Virtualenv 不能继承 GetSitePackages() 属性

[英]Virtualenv can not inherit GetSitePackages() Attribute

I just installed TensorFlow under VirtualEnv on Mac OSX El Capitan.我刚刚在 Mac OSX El Capitan 上的 VirtualEnv 下安装了 TensorFlow。 Now I am trying to understand the structure by following examples given in tensorflow.org website.现在我试图通过以下 tensorflow.org 网站中给出的示例来理解结构。

I am new to python and its syntax.我是 python 及其语法的新手。 But as far as I can figure out the attribute called getsitepackages() is kind of important in order to list modules' attributes easily.但据我所知,名为 getsitepackages() 的属性对于轻松列出模块的属性非常重要。 But with its default python and virtualenv version on el capitan, it seems that virtualenv can not inherit getsitepackages() attribute of the module called "site".但是在 el capan 上使用其默认的 python 和 virtualenv 版本,virtualenv 似乎无法继承名为“site”的模块的getsitepackages()属性。

Hence I couldn't run the simple example command ( python -c 'import site; print("\\n".join(site.getsitepackages()))' ) to locate tensorflow libraries.因此,我无法运行简单的示例命令( python -c 'import site; print("\\n".join(site.getsitepackages()))' )来定位 tensorflow 库。

I guess this is a known bug but I couldn't find a way to solve this issue.我想这是一个已知的错误,但我找不到解决此问题的方法。 I just wonder if anyone has already came up with and solved this problem?我只是想知道是否有人已经想出并解决了这个问题?

PS Outside the virtualenv getsitepackages() just works fine. PS 在 vi​​rtualenv getsitepackages()之外工作正常。 But in the virtualenv I get the following error但是在 virtualenv 中我收到以下错误

python -c 'import site; print("\n".join(site.getsitepackages()))'

Traceback (most recent call last):

File "< string >", line 1, in < module >

AttributeError: 'module' object has no attribute 'getsitepackages'

This seems to be a problem with sites.py which dates all the way back to 2012. As mentioned here .这似乎是sites.py一个问题,它的历史可以追溯到2012年。正如这里提到的。

Have a stab at trying to create the virtualenv using a different python version.尝试使用不同的 python 版本创建 virtualenv。 For example:例如:

virtualenv -p python3 virtualenvname

It's worth checking what python version you're running ( python --version ).值得检查您正在运行的 python 版本( python --version )。 This seems to only be a problem with python2.7 - earlier versions like python2.6 do not experience this problem however they lack a lot of useful packages that were added in python2.7 .这似乎只是python2.7一个问题——像python2.6这样的早期版本没有遇到这个问题,但是它们缺少很多在python2.7中添加的有用包。

My recommendation would be to run it under python3 or python3.4 .我的建议是在python3python3.4下运行它。 TensorFlow seems to support python3 with the 0.6.0 release . TensorFlow 似乎在0.6.0 版本中支持python3

Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM