简体   繁体   English

python pydictionary 不会导入?

[英]python pydictionary wont import?

When I call pip freeze it lists pydictionary as being an installed module, and when i call pydictionary in terminal, it does stuff but if i try to import PyDictionary into my python, it says the module does not exist?当我调用 pip freeze 时,它​​将 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

and

$ pip freeze

...
pycosat==0.6.1
pycparser==2.17
pycrypto==2.6.1
pycurl==7.43.0
PyDictionary==1.5.2
...

but但是

$ 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'

As written in the docs: https://pypi.python.org/pypi/PyDictionary如文档中所写: https : //pypi.python.org/pypi/PyDictionary

from PyDictionary import PyDictionary
dictionary = PyDictionary()

print (dictionary.meaning("indentation"))

output:输出:

{'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']

}

UPDATE: Based on the discussion in comments, In sublime add a new build system更新:基于评论中的讨论,在 sublime 添加一个新的构建系统

Tools->build system-> new build systems add工具->构建系统->新构建系统添加

{
    "cmd": ["/Users/<user>/anaconda3/bin/python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

Switch build system to this build system and try build.将构建系统切换到此构建系统并尝试构建。

I have this problem also, so I switched to dictionary.我也有这个问题,所以我切换到字典。 Install it using:使用以下方法安装它:

pip install dictionary

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM