我正在尝试在我的Mac书上安装Psycopg2.我仍然得到同样的错误.我在Stack Overflow上发现了很多相同的问题,但似乎没有答案可行.我认为它已经过时了.我正在使用:
Mac osx 10.9.5
Python 3.4.3
Run Code Online (Sandbox Code Playgroud)
我的错误代码是:
运行setup.py egg_info for package psycopg2错误:找不到pg_config可执行文件.
请将包含pg_config的目录添加到PATH,或使用以下选项指定完整的可执行文件路径:
python setup.py build_ext --pg-config/path/to/pg_config build ...
或者使用'setup.cfg'中的pg_config选项.从命令python setup.py egg_info完成输出:运行egg_info
写pip-egg-info/psycopg2.egg-info/PKG-INFO
将顶级名称写入pip-egg-ps/psycopg2.egg-info/top_level.txt
将dependency_links写入pip-egg-info/psycopg2.egg-info/dependency_links.txt
警告:manifest_maker:找不到标准文件'-c'
错误:找不到pg_config可执行文件.
请将包含pg_config的目录添加到PATH
或使用以下选项指定完整的可执行文件路径:
python setup.py build_ext --pg-config/path/to/pg_config build ...
或者使用'setup.cfg'中的pg_config选项.
命令python setup.py egg_info失败,错误代码为1/Users/stevengerrits/build/psycopg2存储完整的登录/Users/stevengerrits/Library/Logs/pip.log
我有一个相同模型类型的对象列表。我想遍历此列表并创建一个JSON以发送回去。我尝试了2维数组,谷歌(Google)等东西,但找不到类似的东西?虽然我认为这并不困难。
我的代码现在是:
def get_cashflows(request):
response_data = {}
cashflow_set = Cashflow.objects.all();
i = 0;
for e in cashflow_set.iterator():
c = Cashflow(value=e.value, date=str(e.date));
response_data[i] = c;
return HttpResponse(
json.dumps(response_data),
content_type="application/json"
)
Run Code Online (Sandbox Code Playgroud)
这里不可能在json.dumps中给出模型。但是我如何给它多一个对象呢?
错误:
TypeError: coercing to Unicode: need string or buffer, float found
[08/Sep/2016 14:14:00] "GET /getcashflow/ HTTP/1.1" 500 85775
Run Code Online (Sandbox Code Playgroud) 我有一个 Pandas Dataframe,其日期列具有以下结构:
352 [2012-01-12 05:04:58]
353 [2008-07-16 20:38:21]
354 [2009-05-12 01:05:48]
355 [2012-01-12 05:04:58]
356 [2018-01-05 15:06:41]
357 [2017-07-17 22:03:43]
Name: Date, Length: 358, dtype: object
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,这些是带有 的“对象”。我想将它们转换为 Datetime 对象。所以我使用了 pandas 函数:
pd.to_datetime(df['Date'])
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
Traceback (most recent call last):
File "/anaconda3/envs/py35thesis/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 3267, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-185-adf5e63a666b>", line 1, in <module>
pd.to_datetime(df['Date'])
File "/anaconda3/envs/py35thesis/lib/python3.5/site-packages/pandas/core/tools/datetimes.py", line 451, in to_datetime
values = _convert_listlike(arg._values, True, format)
File "/anaconda3/envs/py35thesis/lib/python3.5/site-packages/pandas/core/tools/datetimes.py", line 368, in _convert_listlike
require_iso8601=require_iso8601
File "pandas/_libs/tslib.pyx", line 492, in pandas._libs.tslib.array_to_datetime …Run Code Online (Sandbox Code Playgroud) 我有 2 个数据框需要合并。两者都有相同的日期时间。我需要比较日期时间并按日期时间将 DF A 的值添加到相应的 DF B 行。让我们看看数据框:
df[“日期”]:
2013 2016-06-06
2174 2016-06-07
1432 2016-06-08
2035 2016-06-09
278 2016-06-10
2250 2016-06-11
908 2016-06-12
702 2016-06-13
1982 2016-06-14
630 2016-06-15
Name: Date, Length: 81, dtype: object
Run Code Online (Sandbox Code Playgroud)
股票[“日期”]
47 2016-06-02
48 2016-06-03
49 2016-06-06
50 2016-06-07
51 2016-06-08
52 2016-06-09
53 2016-06-10
54 2016-06-13
55 2016-06-14
56 2016-06-15
Name: Date, dtype: datetime64[ns]
Run Code Online (Sandbox Code Playgroud)
当我尝试通过以下方式合并数据框时:
df.merge(stocks, left_on='Date', right_on='Date')
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Traceback (most recent call last):
File "/anaconda3/envs/py35thesis/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 3267, in run_code
exec(code_obj, self.user_global_ns, self.user_ns) …Run Code Online (Sandbox Code Playgroud) 我正在使用 MAMP 在我的本地主机上使用 SQL 数据库工作。
当我尝试打开“PhPMyAdmin”(工具->phpMyAdmin)时出现此错误
配置文件权限错误,不应该是全局可写的!MAMP
我用谷歌搜索它并更改了 config.inc.php 文件的权限,但它仍然不起作用。
我有一个图像滑块,所选图像设置为上面的主图像。所有图像的大小都不相同。如何确保每个图像都位于父 div 和整个父 div 的中心?
我现在正在这样做:
width: 100%;height: 100%;object-fit:fill;
Run Code Online (Sandbox Code Playgroud)
但随后我的图像就失去了其内容的底部。我想将图像垂直居中。
我的父 div 有以下类样式:
.wrapper_image{
max-width:100%;
max-height:100%;
min-height:100%;
min-width: 100%;
margin: 0 auto;
}
Run Code Online (Sandbox Code Playgroud)
代码:
<div class="o-grid__col u-12/12" style="width: 400px;
height: 400px;
position: relative;
display: inline-block;
overflow: hidden;
text-align: center;
margin: 0;">
<div class="mySlides wrapper_image_horses">
<img src='url' style="width: 100%;height: 100%;object-fit:fill;">
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Codeigniter创建一个Web应用程序.但我无法浏览我的网页.示例:我希望页面employee_view中的按钮导航到employeecontroller/addEmployee.我在网上/ stackoverflow搜索了几个小时.尝试了一切,有5个各种错误信息.我厌倦了搜索,希望有人可以帮助我:)
这是我工作区和代码的图片:
我的路线.php:
$route['default_controller'] = 'EmployeeController';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['EmployeeController/addEmployee'] = 'EmployeeController/addEmployee';
$route['EmployeeController/createEmployee'] = 'EmployeeController/createEmployee';
$route['EmployeeController'] = 'application/controllers/EmployeeController';
Run Code Online (Sandbox Code Playgroud)
在config.php我得到:
$config['base_url'] = 'http://localhost:8888/BoMaTec_afstudeerproject/CodeIgniter-3.0.1/';
$config['index_page'] = '';
Run Code Online (Sandbox Code Playgroud)
我的ht.acces文件:[IMG] http://i58.tinypic.com/euq2vk.png [/IMG ]
我有一个带有日期(2 种格式)的 DataFrame 列,我想重新编码为 1 种格式的日期时间。
列值如下所示:
0 2011-11-23 16:13:50
1 2016-02-06
2 2011-11-27
3 2014-04-17 22:41:08
4 2013-12-11 17:08:20
5 2011-08-13
6 2007-07-25
7 2009-03-17 15:55:59
8 2017-08-25
Run Code Online (Sandbox Code Playgroud)
& 很快
我想通过以下命令来做到这一点:
df['Date'] = df['Date'].apply(lambda x: pd.to_datetime(x[0]))
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "/Users/stevengerrits/miniconda3/envs/py35thesis/lib/python3.5/site-packages/pandas/core/tools/datetimes.py", line 377, in _convert_listlike
values, tz = conversion.datetime_to_datetime64(arg)
File "pandas/_libs/tslibs/conversion.pyx", line 188, in pandas._libs.tslibs.conversion.datetime_to_datetime64
TypeError: Unrecognized value type: <class 'str'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File …Run Code Online (Sandbox Code Playgroud) 我想迭代一个 dict 并用数据做一些计算。但我不想要 NoneType 数据,否则我会收到错误消息。所以我这样做:
sum_value = 0 if values.get("sum", 0) is None else values.get("sum", 0)
Run Code Online (Sandbox Code Playgroud)
在 Python 中没有更好的方法来做到这一点吗?