2017-08-02 41 views
0

當我調用pip凍結時,它列出了pydictionary作爲一個已安裝的模塊,並且當我在終端中調用pydictionary時,它執行了一些操作,但是如果我嘗試將PyDictionary導入到我的python中,它說模塊不存在?python pydictionary將不會導入?

$ 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

試圖導入PyDictionary而不是? Python中的字母事件 – Peni

回答

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

} 

UPDATE:基於對意見的討論,在崇高添加一個新的構建系統

工具 - >打造系統 - >新建系統添加

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

交換機構建系統這個構建系統並嘗試構建。

+0

嗨,這個工程在我的終端中 $ python Python 3.6.0 | Anaconda 4.3.1(64-bit)| (默認,2016年12月23日,12:22:00) [GCC 4.4.7 20120313(Red Hat 4.4.7-1)] on linux 輸入「help」,「copyright」,「credits」或「license」更多信息。 >>>從PyDictionary進口PyDictionary >>>字典= PyDictionary() 但不是當我把它在我的代碼,其中「從PyDictionary進口PyDictionary」給我的錯誤 「文件」 /家/ NAME /Desktop/FOLDER/FOLDER/FOLDER/knock.py「,第2行,在 from PyDictionary import PyDictionary ImportError:沒有名爲PyDictionary的模塊」 – user8406345

+0

因爲你安裝了Anaconda。所以當你運行'knock.py'時,它正在訪問的python庫與'python' shell不同。 –

+0

你用什麼命令來運行'/ home/NAME/Desktop/FOLDER/FOLDER/FOLDER/knock.py'? –