feeicn / dict Goto Github PK
View Code? Open in Web Editor NEWChinese and English translation tools in the command line(命令行下中英文翻译工具)
License: MIT License
Chinese and English translation tools in the command line(命令行下中英文翻译工具)
License: MIT License
似乎是有道的 API 访问被限制了?
一直在用这个简单的工具, 最近好像不能用了? 报错信息
Traceback (most recent call last):
File "/usr/local/bin/dict", line 130, in <module>
Dict(sys.argv[1:])
File "/usr/local/bin/dict", line 44, in __init__
self.translate()
File "/usr/local/bin/dict", line 50, in translate
self.content = json.loads(content.decode('utf8'))
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Traceback (most recent call last):
File "/usr/bin/dict", line 6, in
from pkg_resources import load_entry_point
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 3095, in
@_call_aside
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 3079, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 3108, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 561, in _build_master
ws = cls()
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 554, in init
self.add_entry(entry)
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 610, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1958, in find_on_path
for dist in factory(fullpath):
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2028, in distributions_from_metadata
root, entry, metadata, precedence=DEVELOP_DIST,
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2467, in from_location
py_version=py_version, platform=platform, **kw
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2842, in _reload_version
md_version = _version_from_file(self._get_metadata(self.PKG_INFO))
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2431, in _version_from_file
line = next(iter(version_lines), '')
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 2621, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1404, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1400, in get_metadata
value = self._get(self._fn(self.egg_info, name))
File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1512, in _get
with open(path, 'rb') as stream:
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.6/site-packages/idna-2.7-py3.6.egg-info/PKG-INFO'
^CTraceback (most recent call last):
File "/usr/local/bin/dict", line 10, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/dict/init.py", line 142, in main
Dict(sys.argv[1:])
File "/usr/local/lib/python2.7/dist-packages/dict/init.py", line 53, in init
self.translate()
File "/usr/local/lib/python2.7/dist-packages/dict/init.py", line 59, in translate
content = urlopen(self.api).read()
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 429, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 447, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1228, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1195, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
File "/usr/lib/python2.7/httplib.py", line 1057, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1097, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 897, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 859, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 836, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 566, in create_connection
sock.connect(sa)
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
KeyboardInterrupt
± dict test
File "/usr/local/bin/dict", line 27
print 'ERROR'
^
SyntaxError: Missing parentheses in call to 'print'
是因为我python版本的问题吗?我环境默认好像是3.x的
翻译结果可以全部另起一行,这样就不会有对齐问题了。
###################################
# 过时 Out of date
# (Pinyin: guò shí)
#
# outmoded
# out of style
# go out
# out of fashion
# behind the times
#
# 过时 : go out
# out of date
# Obsolescence
# 过时的 : out of date
# outdated
# obsolete
# 过时了 : behind the times
# go out of fashion
# out of date
###################################
➜ ~ dict 测试
Traceback (most recent call last):
File "/usr/local/bin/dict", line 9, in
load_entry_point('dict-cli==1.3.4', 'console_scripts', 'dict')()
File "build/bdist.macosx-10.11-intel/egg/dict/init.py", line 143, in main
File "build/bdist.macosx-10.11-intel/egg/dict/init.py", line 51, in init
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)
系统是 OS X EI Capitan 10.11
when i run command like dict hello
then it show me an error:
TypeError: $ is not a function
after reading your code , i solved this problem.
source.js 1:1
const $ = require('cheerio')
change to
const $ = require('cheerio').load
so it worked!
but i really want to know what reason causes you to remove .load
?
i hope you reply me
如题!
Hope for upgrade this project!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.