当我调用pip冻结时,它将pydictionary列为已安装的模块,当我在终端中调用pydictionary时,它确实有用,但是如果我尝试将PyDictionary导入到我的python中,它说该模块不存在?
$ pydictionary
results is
Enter words in a string separated by commas: Enter words in a string separated by commas: happy, ever
PyDictionary:
/home/ME/anaconda3/lib/python3.6/site-packages/bs4/__init__.py:181: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
The code that caused this warning is on line 11 of the file /home/ME/anaconda3/bin/pydictionary. To get rid of this warning, change code that looks like this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "lxml")
markup_type=markup_type))
Happy:
Adjective:
enjoying or showing or marked by joy or pleasure
marked by good fortune
eagerly disposed to act or to be of service
well expressed and to the point
Ever:
Adverb:
at any time
at all times; all the time and on every occasion
(intensifier for adjectives
和
$ pip freeze
...
pycosat==0.6.1
pycparser==2.17
pycrypto==2.6.1
pycurl==7.43.0
PyDictionary==1.5.2
...
但
$ python
Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydictionary
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pydictionary'
答案 0 :(得分:1)
如文档中所述:https://pypi.python.org/pypi/PyDictionary
from PyDictionary import PyDictionary
dictionary = PyDictionary()
print (dictionary.meaning("indentation"))
输出:
{'Noun': ['a concave cut into a surface or edge (as in a coastline', 'the
formation of small pits in a surface as a consequence of corrosion', 'th
e space left between the margin and the start of an indented line', 'the
act of cutting into an edge with toothlike notches or angular incisions']
}
更新:根据评论中的讨论,在sublime中添加一个新的构建系统
工具 - &gt;构建系统 - &gt;新构建系统添加
{
"cmd": ["/Users/<user>/anaconda3/bin/python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
将构建系统切换到此构建系统并尝试构建。
答案 1 :(得分:0)
我也有这个问题,所以我改用字典。使用以下命令安装它:
pip install dictionary