为什么pyhton会出现这个错误? [英] Why this error in pyhton?

查看:137
本文介绍了为什么pyhton会出现这个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 来自 nltk.tokenize  import  RegexpTokenizer 
< span class =code-keyword>来自停用词 import get_stop_words
来自 nltk.stem.porter import 来自 gensim的 import corpora,model
import gensim





错误:

RESTART:C:\ Users \Administrator \Desktop\PythonLDA \stop_words \ MyFirstPythonProgram.py

Traceback(最近一次调用最后一次):

文件C:\ Users \Administrator \Desktop \PythonLDA \stop_words \ MyFirstPythonProgram.py,第4行,在< module>

来自gensim import corpora,models

文件C:\ Users \Administrator \Desktop \\ \\ _PythonLDA \stop_words\gensim\__init __。py,第6行,在< module>

来自gensim导入解析,matutils,接口,语料库,模型,相似性,摘要
文件C:\ Users \Administrator \Desktop\PythonLDA \stop_words \gensim\parsing\__init __。py,第6行,在< module>
$来自.porter的b $ b导入PorterStemmer

文件C:\ Users \Administrator \Desktop\PythonLDA\stop_words\gensim\parsing\porter.py,第35行,在< module>

from six.moves import xrange

ModuleNotFoundError:没有名为'six'的模块



我尝试过:



已验证,文件夹存在gensim



里面还有文件夹语料库和模型都存在。



在解析文件夹中,有一个名为porter.py的文件。

我打开此文件并检查第35行写的地方



 来自 six.moves  import  xrange 





当我下载 <时,我在这一行正好收到错误u> six-1.10.0.tar.gz 模块并将six.py文件放在同一个项目文件夹中

解决方案

< pre lang =text>已验证,文件夹存在gensim

里面还有文件夹语料库和模型都存在。

在解析文件夹中,有一个名为porter.py的文件。
我打开了这个文件并检查了第35行这里写的是





通过上述陈述,我怀疑有很多python文件,所以它必须是一个库。



将有一个setup.py使用setup.py命令安装它如果还有问题感觉免费发表评论!



更新:



嗯,我没有足够的信息你的Python环境就像版本一样(像我一样有两个版本,如2.x和3.x在同一系统上运行),你所在的系统等等,所以我将解释如何从源代码安装库(不使用pip或easy_install等,)



步骤1:

1.解压缩压缩文件夹并打开它,你会发现一个设置。 py文件里面



第2步:

(a)FOR WINDOWS:



按住并单击鼠标右键,您会在其中找到打开命令窗口选项以下命令



 setup.py install 





安装前请注意你的python在路径中,



要检查它打开命令提示符并键入python你应该找到IDLE的命令行版本!



(b)对于LINUX:



Linux通常附带两个版本的Python- 2.x,3.x(至少基于Debian的口味),如Ubuntu,Kali等,



其中pwd是目前的工作目录,



python pwd + setup.py安装这将在python 2中安装库



python3 pwd + setup.py install这将在python 3中安装库


from nltk.tokenize import RegexpTokenizer
from stopwords import get_stop_words
from nltk.stem.porter import PorterStemmer
from gensim import corpora, models
import gensim



Error:
RESTART: C:\Users\Administrator\Desktop\PythonLDA\stop_words\MyFirstPythonProgram.py
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\PythonLDA\stop_words\MyFirstPythonProgram.py", line 4, in <module>
from gensim import corpora, models
File "C:\Users\Administrator\Desktop\PythonLDA\stop_words\gensim\__init__.py", line 6, in <module>
from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization
File "C:\Users\Administrator\Desktop\PythonLDA\stop_words\gensim\parsing\__init__.py", line 6, in <module>
from .porter import PorterStemmer
File "C:\Users\Administrator\Desktop\PythonLDA\stop_words\gensim\parsing\porter.py", line 35, in <module>
from six.moves import xrange
ModuleNotFoundError: No module named 'six'

What I have tried:

Verified,folder exists gensim

also inside there are both folder corpora and models exists.

Inside parsing folder , there is a file named porter.py.
I opened this file and checked the line no 35 where this is written

from six.moves import xrange



I am getting error exactly on this line while i downloaded six-1.10.0.tar.gz module and place the six.py file in the same project folder

解决方案

Verified,folder exists gensim

also inside there are both folder corpora and models exists.

Inside parsing folder , there is a file named porter.py.
I opened this file and checked the line no 35 where this is written



By the above statements by you I suspect that there are many python files and so it must be a library.

There will be a setup.py install it using setup.py command If there is still a problem feel free to post comments!

UPDATE:

Well, I don't have any sufficient information about your Python environment like version(some like me have both versions like 2.x and 3.x running on the same system), The system you are in etc., so I'll explain how to install a library from source(without using pip or easy_install etc.,)

Step 1:
1. Extract the compressed folder and open it and you will find a setup.py file in it

Step 2:
(a) FOR WINDOWS:

press and hold the right mouse click and you will find "Open command window" option there type the following command

setup.py install



before installing please note that your python is in path,

To check it open a command prompt and type python you should find command line version of IDLE shown up!

(b) For LINUX:

Linux is usually shipped with both the versions of Python-2.x,3.x (at-least Debian based flavors) like Ubuntu, Kali etc.,

where pwd is a present working directory,

python pwd+setup.py install this will install the library in python 2

python3 pwd+setup.py install this will install the library in python 3


这篇关于为什么pyhton会出现这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆