无法在python3.6和ubuntu中导入ethjsonrpc

时间:2018-09-11 08:58:06

标签: python ubuntu encode ethereum

导入ethjsonrpc时会引发如下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/ethjsonrpc/__init__.py", line 1, in <module>
    from ethjsonrpc.client import (EthJsonRpc, ParityEthJsonRpc,
  File "/usr/local/lib/python3.6/site-packages/ethjsonrpc/client.py", line 7, in <module>
    from ethereum import utils
  File "/usr/local/lib/python3.6/site-packages/ethereum/utils.py", line 103, in <module>
    assert sha3('').encode('hex') == 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
AttributeError: 'bytes' object has no attribute 'encode'

1 个答案:

答案 0 :(得分:1)

这是<?php namespace App\Nova\Lenses; use Laravel\Nova\Fields\ID; use Illuminate\Http\Request; use Laravel\Nova\Fields\Text; use Laravel\Nova\Lenses\Lens; use Laravel\Nova\Fields\Number; use Illuminate\Support\Facades\DB; use Laravel\Nova\Http\Requests\LensRequest; class MostValuableUsers extends Lens { /** * Get the query builder / paginator for the lens. * * @param \Laravel\Nova\Http\Requests\LensRequest $request * @param \Illuminate\Database\Eloquent\Builder $query * @return mixed */ public static function query(LensRequest $request, $query) { return $request->withOrdering($request->withFilters( $query->select($this->columns()) ->join('licenses', 'users.id', '=', 'licenses.user_id') ->orderBy('revenue', 'desc') ->groupBy('users.id', 'users.name') )); } /** * Get the columns that should be selected. * * @return array */ protected function columns() { return [ 'users.id', 'users.name', DB::raw('sum(licenses.price) as revenue'), ]; } /** * Get the fields available to the lens. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return [ ID::make('ID', 'id'), Text::make('Name', 'name'), Number::make('Revenue', 'revenue', function ($value) { return '$'.number_format($value, 2); }), ]; } /** * Get the filters available for the lens. * * @param \Illuminate\Http\Request $request * @return array */ public function filters(Request $request) { return []; } /** * Get the URI key for the lens. * * @return string */ public function uriKey() { return 'most-profitable-users'; } } 的问题,如github issue page所示。提议的解决方法是仅注释ethjsonrpc

中的第103行

最好改用python2来使用此模块,以防由于版本差异而导致出现更多错误。