简体   繁体   English

ModuleNotFoundError:没有名为“将熊猫作为pd \\ r导入”的模块

[英]ModuleNotFoundError: No module named 'mport pandas as pd\r'

ModuleNotFoundError: No module named 'mport pandas as pd\\r' ModuleNotFoundError:没有名为“将熊猫作为pd \\ r导入”的模块

but not getting any line in the source code 'mport pandas as pd/r' 但在源代码“以pd / r格式导入pandas”中没有得到任何一行

This is code part nothing here like mport not even in the other file that is imported in the code. 这是代码部分,这里没有mport,甚至在代码中导入的其他文件中也没有。

{ 
import cv2
import numpy as np
import pandas as pd
import nltk
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics import pairwise_distances
import pickle
from utils import display_img

data = pd.read_pickle('pickles/dataclean.py')

stop_words = set(nltk.corpus.stopwords.words('english'))
def nlp_preprocessing(total_text, index, column):
    if type(total_text) is not int:
        string = ""
        for words in total_text.split():
            # remove the special chars in review like '"#$@!%^&*()_+-~?>

dataclean.py dataclean.py

{import pandas as pd
# loading the data using pandas' read_json file.
data = pd.read_json('data/tops_fashion.json')
data = data.loc[~data['formatted_price'].isnull()]#this will remove data with no price
data =data.loc[~data['color'].isnull()]#remove data with no color
#print(sum(data.duplicated('title')))#tell about dubplicate  
from remove_duplicate import remove_dup1,remove_dup2   
data=remove_dup1(data)#removes adjacent sorted same title
data=remove_dup2(data)#this will take time approx half hour
data.to_pickle('pickels/dataclean')}

nothing is in dataclean.py related to mport even i searched it on google but no detail is available related to this error Generally "mport" kind of error related to syntax error but no such error mentioned on other side it tried to search for the related module dataclean.py中没有任何与mport相关的内容,即使我在Google上进行了搜索,但没有与此错误相关的详细信息。通常,“ mport”类型的错误与语法错误相关,但在另一侧没有提及此类错误,因此它尝试搜索相关的错误模组

this code is related to product recommendation system 该代码与产品推荐系统有关

Expected Result: Should run smoothly //Error code Actual Result: 预期结果:应该运行平稳//错误代码实际结果:

Traceback (most recent call last):
  File "recom.py", line 11, in <module>
    data = pd.read_pickle('pickles/dataclean.py')
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\io\pickle.py", line 180, in read_pickle
    return try_read(path, encoding='latin1')
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\io\pickle.py", line 175, in try_read
    lambda f: pc.load(f, encoding=encoding, compat=True))
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\io\pickle.py", line 149, in read_wrapper
    return func(f)
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\io\pickle.py", line 175, in <lambda>
    lambda f: pc.load(f, encoding=encoding, compat=True))
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\compat\pickle_compat.py", line 212, in load
    return up.load()
  File "C:\Users\DELL\Anaconda3\lib\pickle.py", line 1050, in load
    dispatch[key[0]](self)
  File "C:\Users\DELL\Anaconda3\lib\pickle.py", line 1309, in load_inst
    klass = self.find_class(module, name)
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\compat\pickle_compat.py", line 135, in find_class
    return super(Unpickler, self).find_class(module, name)
  File "C:\Users\DELL\Anaconda3\lib\pickle.py", line 1388, in find_class
    __import__(module, level=0)
ModuleNotFoundError: No module named 'mport pandas as pd\r'}
  File "recom.py", line 11, in <module> data = pd.read_pickle('pickles/dataclean.py') //dataclean.py {import pandas as pd 

You are trying to load a Python file as a pickle. 您正在尝试将Python文件加载为pickle。 Python and pickle are two completely different formats, so this is never gonna work. Python和pickle是两种完全不同的格式,因此永远无法使用。 I don't know what you are trying to do, or who suggested you to put Python code into curly braces to boot, but this is one of the craziest things I've ever seen people try. 我不知道您要做什么,还是谁建议您将Python代码放在​​花括号中启动,但这是我见过的人们尝试过的最疯狂的事情之一。

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

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