如果我正确关注https://docs.python.org/2/library/site.html,我需要将 site-packages 目录移动到 /usr/lib/python2.7 或将 sys.prefix 更改为 /用户/本地。
前者好像不对。对于后者,我可以找到的选项是直接编辑 site.py 或重新安装 python。编辑 site.py 是否被认为太老套了,还是标准的做法?(ETA:我认为这是一件标准的事情,因为这就是它的用途。我想我真的在问这是否是这种情况下的最佳选择。)
还是我忽略了另一种选择?
/usr/lib 与 /usr/local/lib:
auto@virgo:/etc/apache2$ ls -ld /usr/lib/python2.7/site-packages
ls: cannot access /usr/lib/python2.7/site-packages: No such file or directory
auto@virgo:/etc/apache2$ ls -ld /usr/local/lib/python2.7/site-packages
drwxrwsr-x 2 root staff 4096 Aug 29 2013 /usr/local/lib/python2.7/site-packages
Run Code Online (Sandbox Code Playgroud)
python sys.prefix:
auto@virgo:~$ python
Python 2.7.3 (default, Apr 10 2013, 05:46:21)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.prefix
/usr
Run Code Online (Sandbox Code Playgroud)
谢谢!
我一直在尝试使用elasticsearch.jquery.min.js ping本地运行的elasticsearch,每次都会出现"无生命连接"错误.
ETA:在Chrome中我看到的是一个非常低级别的"拒绝连接".我正在开发MacOS X,我的浏览器指向页面http://localhost/~myuserid/SiteName/.因为我访问localhost:9200它显然属于跨域CORS要求.
我在Chrome控制台中看到以下错误:
XMLHttpRequest cannot load http://localhost:9200/?hello=elasticsearch!.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)
根据http://enable-cors.org/server_apache.html我已将以下内容添加到/etc/apache2/httpd.conf中:
<Directory />
Header set Access-Control-Allow-Origin "localhost:9200"
AllowOverride none
Require all denied
</Directory>
Run Code Online (Sandbox Code Playgroud)
并运行
$ sudo apachectl -t
$ sudo apachectl -k graceful
Run Code Online (Sandbox Code Playgroud)
但错误仍然存在.我还有另一种设置吗?
我是elasticsearch.js的菜鸟.我是否需要在弹性搜索方面做任何事情以允许来自浏览器的客户端连接,或者什么?
我正在读这本书尝试ping:
var client = new $.es.Client({
hosts: 'localhost:9200'
});
client.ping(
{
requestTimeout: Infinity,
// undocumented params are appended to the query string …Run Code Online (Sandbox Code Playgroud) ETA:在 terraform github 问题中找到了讨论,https://github.com/hashicorp/terraform/issues/13103。已知且非常......“特殊”......问题。
传递一个列表通过其它两个模块(从后top.tf通autoscaling_group到launch_configuration),这两者都定义为可变type = "list",我是从得到以下投诉terraform plan:
"Error: module.autoscaling_group.aws_launch_configuration.this:
security_groups: should be a list"
Run Code Online (Sandbox Code Playgroud)
它似乎将参数识别为列表类型(如果我从变量声明中删除类型规范,它会抱怨)。但是我发现消除错误的唯一方法是将最终用法包装在列表括号中。这似乎违反直觉(我还没有看到这样做时会发生apply什么) - 发生了什么?
序列:
top.tf调用security_group。top.tf还调用autoscaling,传递带有安全组id输出的列表。autoscaling调用launch_configuration,传递参数。这是布局,.tf 文件的内容如下。
.
??? autoscaling_group
? ??? main.tf
??? launch_configuration
? ??? main.tf
??? security_group
? ??? main.tf
??? top.tf
Run Code Online (Sandbox Code Playgroud)
发起调用top.tf是:
module "autoscaling_group" {
source = "launch_configuration"
security_groups = ["${module.security_group.id}"]
} …Run Code Online (Sandbox Code Playgroud) 我在使用 boto3 连接到 AWS 的代码时遇到错误。错误刚刚在昨天下午开始,在我最后一次没有收到错误和第一次收到错误之间,我没有看到任何改变。
错误是:
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL:
Run Code Online (Sandbox Code Playgroud)
在 .aws/config 我有:
$ cat ~/.aws/config
[default]
region=us-east-1
Run Code Online (Sandbox Code Playgroud)
这是我所知道的:
我不认为我在上次有效和第一次无效之间改变了任何会影响这一点的东西。似乎我不得不更改我这边的一些 AWS 特定配置或一些低级库,而我没有进行任何此类更改。我和一位同事谈了 30-45 分钟,当我回来并从我离开的地方开始时,这个问题首先出现了。
关于解决此问题的任何想法或想法?
完整的异常转储如下。
$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> boto3.client('ec2').describe_regions()
Traceback (most recent call last):
File "<stdin>", line 1, in <module> …Run Code Online (Sandbox Code Playgroud) 我正在为这种情况寻找一两个好的习语:
我想使用异步反向地理定位调用将 CLLocationCooperative2D 转换为 CLPlacemark,作为一系列其他操作的一部分。
转换步骤在很大程度上是一个“实用”步骤,因此在处理程序中放入大量代码来执行“其他操作”感觉结构很差。
我可以将结果存储在类变量中,但我需要知道异步步骤何时完成,这意味着某种事件触发或主线程排队超时或其他什么,这也看起来很尴尬。
有标准方法吗?将代码放入处理程序中是否很常见?
谢谢!
这是我的上下文的具体代码,FWIW。
func getPlaceFromCoordinate(coordinate: CLLocationCoordinate2D) -> CLPlacemark? {
var loc = CLLocation(
latitude: coordinate.latitude,
longitude: coordinate.longitude
)
var mightBeAPlace: CLPlacemark? = nil
CLGeocoder().reverseGeocodeLocation(loc, completionHandler: {(placemarks, error) -> Void in
if(error != nil) {
println("Reverse geocoding error.")
}
else if (placemarks.count == 0) {
println("no placemarks")
}
else { // if (placemarks.count > 0)
println("we have placemarks")
mightBeAPlace = CLPlacemark(placemark: placemarks[0] as! CLPlacemark)
println("Inside closure place: \(mightBeAPlace?.locality)")
lastUserSelectedPlace = mightBeAPlace // This stores …Run Code Online (Sandbox Code Playgroud)