缺少 numpy.random.common

我使用python的tkinter编写了一个程序,用pyinstaller编译之后,程序提示
failed to execute script 文件名
错误提示:
no module named 'numpy.random.common'
可是我重新pip numpy模块还是不好用 请问怎么解决?

#!/usr/bin/python 
# -- coding: utf-8 --
import fnmatch  #选择文件的关键词
import os
from time import sleep
from tkinter import *
import tkinter.filedialog #弹出选择路径的库
import tkinter.messagebox
import fnmatch  #选择文件的关键词
import re
import pandas as pd
import docx
import pickle
import  codecs
import string
import shutil
from win32com import client as wc



def matchdocname(str1,root,i,list_box):
    if str1 in os.path.splitext(i)[0]:
        list_box.insert(END, root+"/"+i)
def matchdoccontent(str1,root,i,list_box):   
    if i.endswith('txt'):                                               #当文件为txt时
        with open(os.path.join(root, i) ,'r') as fp:
            errors=''
            aa=fp.read()
            if str1 in aa :
                list_box.insert(END, root+"/"+i)  
    if i.endswith('xls') or i.endswith('xlsx') :                        #当文件为excel时
        df=pd.read_excel(os.path.join(root, i))
        df=df.values
        for k in df:
            for j in k:
                j=str(j)
                if  str1 in j:
                    list_box.insert(END, root+"/"+i)
    if i.endswith('docx'):                                               #当文件为.docx时
        word = wc.Dispatch('Word.Application')
        doc = word.Documents.Open(os.path.join(root, i))      
        newname=os.path.join(root, i)+"(translate txt)" 
        doc.SaveAs(newname,4)   
        doc.Close()
        word.Quit()
        with open(newname ,'r') as fp:
            errors=''
            aa=fp.read()
            if str1 in aa :
                list_box.insert(END, root+"/"+i)
        os.remove(newname)                                  
    if i.endswith('doc'):                                               #当文件为.doc时  
        word = wc.Dispatch('Word.Application')
        doc = word.Documents.Open(os.path.join(root, i))      
        newname=os.path.join(root, i)+"(translate txt)" 
        doc.SaveAs(newname,4)   
        doc.Close()
        word.Quit()
        with open(newname ,'r') as fp:
            errors=''
            aa=fp.read()
            if str1 in aa :
                list_box.insert(END, root+"/"+i)
        os.remove(newname)                                           #删掉这个临时文件

def left():  
    if not entry.get()  :#检测关键词输入框是否为空
        tkinter.messagebox.showerror("提示信息:","出现以下错误:\n关键词不能为空")#弹出警告框
        return #如果为空不再执行
    if var1.get()==0 and var2.get()==0  :
        tkinter.messagebox.showerror("提示信息:","出现以下错误:\n匹配项不能为空")#弹出警告框
        return #如果为空不再执行
    list_box.delete(0,END)
    path = tkinter.filedialog.askdirectory()#弹出选择路径的窗口,path为获取的路径
    path_list = os.walk(path)#获取一个列表目录的对象
    for root, dirs, files in path_list:
        #print root, dirs, files
        if var1.get()==1 and  var2.get()==0:              #当只匹配文件名时
            list_box.insert(END, '文件名')  
            for i in files:
                matchdocname(entry.get(),root,i,list_box)
        elif var1.get()==0 and var2.get()==1:            #当只匹配文件内容时
            list_box.insert(END, '文件内容')
            for i in files:
                matchdoccontent(entry.get(),root,i,list_box)
        elif var1.get()==1 and  var2.get()==1:            #当既匹配文件名又匹配文件内容时 
            list_box.insert(END, '文件名')  
            for i in files:  
                matchdocname(entry.get(),root,i,list_box)
            list_box.insert(END, '--------------')
            list_box.insert(END, '文件内容')
            for i in files:
                matchdoccontent(entry.get(),root,i,list_box)

def func2(e):
     if not list_box.curselection():#取双击的坐标52
         return
     path = list_box.get(list_box.curselection(),last=None)
     os.startfile(path)



def nagea(e):
    error = ''
    tdir = dirs.get(dirs.curselection())
    if os.path.isfile(tdir):        #如果是文件 则打开
        os.startfile(tdir)
    elif os.path.isdir(tdir):       #如果是文件夹 则调用dols
        setDirAndGo()

def wenjianshu():
    dirs.delete(0,END)
    path = tkinter.filedialog.askdirectory()#弹出选择路径的窗口,path为获取的路径
    doLS1(path)

#双击时调用,双击时,设置背景色为红色,并调用doLS函数打开所选文件
def setDirAndGo(ev=None):
    last = cwd.get()
    dirs.config(selectbackground='red')
    check = dirs.get(dirs.curselection())
    if not check:
        check = os.curdir
    cwd.set(check)
    doLS()

#实现更新目录的核心函数
def doLS(ev=None):
    error = ''
    tdir = cwd.get()
    if not tdir:tdir=os.curdir
        #若路径输入错误,或者打开的是文件,而不是目录,则更新错误提示信息
    if not os.path.exists(tdir):
        error = os.getcwd()+'\\'+tdir + ':未找到文件'
    elif not os.path.isdir(tdir):
        error = os.getcwd()+'\\'+tdir + ':未找到目录'
    if error:
        cwd.set(error)
        top2.update()
        sleep(1)
        cwd.set(os.curdir)
        dirs.config(selectbackground='LightSkyBlue')

        top2.update()
        return

    cwd.set(os.getcwd()+'\\'+tdir)
    top2.update()
    dirlist = os.listdir(tdir)#os.listdir() 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表。
    dirlist.sort()
    os.chdir(tdir)#os.chdir() 方法用于改变当前工作目录到指定的路径。

        #更新界面上方标签内容
    dirl.config(text=os.getcwd())
    top2.update()

    dirs.delete(0,END)
    dirs.insert(END,os.pardir)#os.chdir(os.pardir)  切换到上级目录 即将上级目录.. 插入到dirs对象中

        #把选定目录的文件或文件夹的名字的列表依次插入到dirs对象中
    for eachFile in dirlist:
        dirs.insert(END,eachFile)
        cwd.set(os.curdir)
        dirs.config(selectbackground='LightSkyBlue') 

def doLS1(tdir):
    error = ''
    if not tdir:tdir=os.curdir
        #若路径输入错误,或者打开的是文件,而不是目录,则更新错误提示信息
    if not os.path.exists(tdir):
        error = os.getcwd()+'\\'+tdir + ':未找到文件'
    elif not os.path.isdir(tdir):
        error = os.getcwd()+'\\'+tdir + ':未找到目录'
    if error:
        cwd.set(error)
        top2.update()
        sleep(1)
        cwd.set(os.curdir)
        dirs.config(selectbackground='LightSkyBlue')
        top2.update()
        return

    cwd.set(os.getcwd()+'\\'+tdir)
    top2.update()
    dirlist = os.listdir(tdir)#os.listdir() 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表。
    dirlist.sort
    os.chdir(tdir)#os.chdir() 方法用于改变当前工作目录到指定的路径。

    #更新界面上方标签内容
    dirl.config(text=os.getcwd())
    top2.update()

    dirs.delete(0,END)
    dirs.insert(END,os.pardir)#os.chdir(os.pardir)  切换到上级目录 即将上级目录.. 插入到dirs对象中

        #把选定目录的文件或文件夹的名字的列表依次插入到dirs对象中
    for eachFile in dirlist:
        dirs.insert(END,eachFile)
        cwd.set(os.curdir)
        dirs.config(selectbackground='LightSkyBlue') 


top2 = Tk()
top2.title('营销集约管控中心-文件管理')
top2.geometry('+50+50')#窗口大小,窗口位置
cwd = StringVar(top2)
var=IntVar()
dirl = Label(top2,fg = 'BLUE',font = ('Helvetica',18,'bold'))
dirl.pack()
dirfm = Frame(top2)

dirs = Listbox(dirfm,height=25,width=90)
#通过使用List的bind()方法,将鼠标双击事件绑定,并调用setDirAndGo函数
dirs.bind('<Double-1>',nagea)

dirs.pack(side=LEFT,fill=BOTH)

list_box = Listbox(dirfm,height=25,width=90)
list_box.bind('<Double-Button-1>',func2) #绑定一个双击触发事件
list_box.pack(side=LEFT,fill=BOTH)#显示列表框

dirfm.pack()

#第二个框架bfm,放置按钮
bfm = Frame(top2)
open1 = Button(bfm,text='文件树',command=wenjianshu,activeforeground='white',activebackground='blue')
open1.pack(side=LEFT)
bfm.pack(side=LEFT,fill=BOTH)
#多选框插件
var1 = tkinter.IntVar()  # 用来储存下面勾选项1中返回的0或1
var2 = tkinter.IntVar()  # 用来储存下面勾选项2中返回的0或1

button2=tkinter.Checkbutton(top2,text="匹配文件内容",variable=var2,onvalue=1,offvalue=0)
button2.pack(side=RIGHT,fill=BOTH)
button1=tkinter.Checkbutton(top2,text="匹配文件名",variable=var1,onvalue=1,offvalue=0)
button1.pack(side=RIGHT,fill=BOTH)
#按钮控件
entry = Entry()#输入框实例化
entry.pack(side=RIGHT,fill=BOTH)#输入框
button2=Button(top2,text="关键字",command=left)
button2.pack(side=RIGHT,fill=BOTH)


if __name__ =='__main__':
    #设定初始目录为桌面
    mainloop()

2个回答

我刚好也遇到这个问题,我是通过重新安装numpy 1.16.2 版本解决的

pip uninstall numpy
pip install numpy==1.16.2

希望可以帮到你,我猜测是因为numpy版本的原因

谢谢,果真是版本问题

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python用tar.gz文件安装时出现错误:No module named 'numpy.distutils._msvccompiler' in numpy.distutils及Unable to find vcvarsall.bat
系统win10 64位,python版本3.7.4。 在网上下载了scikit-learn-0.22.tar,解压后利用python setup.py install进行安装时报错。 代码如下: ``` PS C:\Users\TH.Liu> cd E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22 PS E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22> python setup.py install Partial import of sklearn during the build process. E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'project_urls' warnings.warn(msg) E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg) No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils Traceback (most recent call last): File "setup.py", line 303, in <module> setup_package() File "setup.py", line 299, in setup_package setup(**metadata) File "E:\python\lib\site-packages\numpy\distutils\core.py", line 137, in setup config = configuration() File "setup.py", line 182, in configuration config.add_subpackage('sklearn') File "E:\python\lib\site-packages\numpy\distutils\misc_util.py", line 1035, in add_subpackage caller_level = 2) File "E:\python\lib\site-packages\numpy\distutils\misc_util.py", line 1004, in get_subpackage caller_level = caller_level + 1) File "E:\python\lib\site-packages\numpy\distutils\misc_util.py", line 941, in _get_configuration_from_setup_py config = setup_module.configuration(*args) File "sklearn\setup.py", line 86, in configuration cythonize_extensions(top_path, config) File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\__init__.py", line 50, in cythonize_extensions basic_check_build() File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\pre_build_helpers.py", line 70, in basic_check_build compile_test_program(code) File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\pre_build_helpers.py", line 40, in compile_test_program extra_postargs=extra_postargs) File "E:\python\lib\distutils\_msvccompiler.py", line 346, in compile self.initialize() File "E:\python\lib\distutils\_msvccompiler.py", line 239, in initialize vc_env = _get_vc_env(plat_spec) File "E:\python\lib\distutils\_msvccompiler.py", line 135, in _get_vc_env raise DistutilsPlatformError("Unable to find vcvarsall.bat") distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat ``` 实际上,这俩错误我都在网上找过许多解决方式,但都没有用。下载了VS2010并尝试过在cmd中设置VS90COMNTOOLS =%VS100COMNTOOLS%,依然无效。 抱着最后的希望来这里求助……希望能得到解决。 ———————————————————— 2019.12.17 更新: 在安装了VS2015之后,vcvarsall.bat的问题消失了,剩下的只有: ``` E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'project_urls' warnings.warn(msg) E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg) No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils ``` 这些问题了。 大家说PowerShell容易出BUG,我换用CMD后依旧如此。 我依旧没有找到这些报错的解决方案,希望得到大佬的帮助!
fatal error: boost/python/numpy.hpp: No such file or directory
哪个大神能解决这个问题,感激不尽!!! ``` fatal error: boost/python/numpy.hpp: No such file or directory ```
Windows下 sklearn:numpy.ufunc has the wrong size
各位大神求指点,我使用ArcGIS10.3自带的Python2.7.8(NumPy 1.7.1,matplotlib 1.3.0)自己去官网下载安装了scipy0.13.3和scikit-learn0.16.0,在编译scikit learn时出现numpy.dtype size问题,还没有运行其他代码,只是导入库就不行了: print('Hello World') # import numpy & scipy import numpy as np from numpy import linalg from numpy.linalg import norm from scipy.spatial.distance import squareform, pdist # import sklearn. import sklearn from sklearn.manifold import TSNE from sklearn.datasets import load_digits from sklearn.preprocessing import scale print "working" ![图片说明](https://img-ask.csdn.net/upload/201601/02/1451704594_425391.png) 新手跪求指点,万分感谢!
numpy.core.multiarray failed to import
# 问题: 使用cmd执行有import cv2 和 numpy的脚本会出现numpy.core.multiarray failed to import ![图片说明](https://img-ask.csdn.net/upload/201708/09/1502268358_642984.jpg) # 一些情况: **环境:** windows 10 python : 3.5.3 opencv-python: 3.3.0 numpy: 1.13.1 在**cmd**运行python,然后import 也会报错 ![图片说明](https://img-ask.csdn.net/upload/201708/09/1502268427_523346.jpg) numpy也是 ![图片说明](https://img-ask.csdn.net/upload/201708/09/1502268454_158067.jpg) **但是** 直接在cp里面是可以import cv2 和 numpy的, IDLE也可以跑程序(cmd里Python fliename.py失败的 ,用IDLE是可以运行的) # 采取过的措施 1. 重装numpy,opencv,乃至换过32位的Python(因为当时用64位的cmd进Python成功import过,但是并不能跑程序,后来还不行了) 2. pip install -U numpy (网上很多这个答案,其实没有用) 请问各路大神这个是什么原因,是环境变量的问题还是什么?
在Cent OS中复现已发表文章的 神经网络训练过程,报错ValueError: low >= high
``` Traceback (most recent call last): File "trainIEEE39LoadSheddingAgent.py", line 139, in <module> env.reset() File "/root/RLGC/src/py/PowerDynSimEnvDef_v3.py", line 251, in reset fault_bus_idx = np.random.randint(0, total_fault_buses)# an integer, in the range of [0, total_bus_num-1] File "mtrand.pyx", line 630, in numpy.random.mtrand.RandomState.randint File "bounded_integers.pyx", line 1228, in numpy.random.bounded_integers._rand_int64 ValueError: low >= high ``` 报错如上,为什么会这样报错?如何解决?谢谢!
numpy.array()打开图片时像素点表示问题
在应用numpy.array()打开图片 代码如下: ``` i = Image.open('images/numbers/0.1.png') iar = np.array(i, dtype='int64') print(iar) ``` 输出结果中大部分为 [[[255 255 255 255] ...... (即alpha数值有表示出来) 而另一张图片,可能就会输出 [[[255 255 255] ...... (即alpha数值没有表示出来) 想请教一下这是为什么呢,有没有什么办法可以把它们统一起来吗?
pyinstaller打包处理的程序用不了
warn-xxx.txt文件的信息如下,求大佬处理 This file lists modules PyInstaller was not able to find. This does not necessarily mean this module is required for running you program. Python and Python 3rd-party packages include a lot of conditional or optional module. For example the module 'ntpath' only exists on Windows, whereas the module 'posixpath' only exists on Posix systems. Types if import: * top-level: imported at the top-level - look at these first * conditional: imported within an if-statement * delayed: imported from within a function * optional: imported within a try-except-statement IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for yourself tracking down the missing module. Thanks! missing module named pyimod03_importers - imported by PyInstaller.loader.pyimod02_archive (delayed, conditional), c:\program files\python37\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py (top-level) missing module named 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.requirements (top-level), pkg_resources._vendor.packaging.markers (top-level) missing module named 'com.sun' - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional) missing module named com - imported by pkg_resources._vendor.appdirs (delayed) missing module named win32api - imported by distutils.msvccompiler (optional), pkg_resources._vendor.appdirs (delayed, conditional, optional) missing module named win32com.shell - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional) missing module named _uuid - imported by uuid (optional) missing module named netbios - imported by uuid (delayed) missing module named win32wnet - imported by uuid (delayed) missing module named __builtin__ - imported by numpy.core.numerictypes (conditional), numpy.core.numeric (conditional), numpy.lib.function_base (conditional), numpy.lib._iotools (conditional), numpy.ma.core (conditional), numpy.distutils.misc_util (delayed, conditional), numpy (conditional), pymysql._compat (conditional), pkg_resources._vendor.pyparsing (conditional), setuptools._vendor.pyparsing (conditional) missing module named ordereddict - imported by pkg_resources._vendor.pyparsing (optional), setuptools._vendor.pyparsing (optional) missing module named StringIO - imported by PyInstaller.lib.modulegraph._compat (conditional), PyInstaller.lib.modulegraph.zipio (conditional), setuptools._vendor.six (conditional), numpy.lib.utils (delayed, conditional), numpy.lib.format (delayed, conditional), numpy.testing._private.utils (conditional), six (conditional), urllib3.packages.six (conditional), requests.compat (conditional), selenium.webdriver.remote.webelement (optional), pkg_resources._vendor.six (conditional) missing module named _scproxy - imported by urllib.request (conditional) missing module named 'macholib.MachO' - imported by PyInstaller.depend.dylib (delayed), PyInstaller.depend.bindepend (delayed), PyInstaller.utils.osx (top-level) missing module named macholib - imported by PyInstaller.depend.dylib (delayed, conditional) missing module named _pkgutil - imported by PyInstaller.lib.modulegraph.modulegraph (delayed, optional) missing module named dis3 - imported by PyInstaller.lib.modulegraph._compat (conditional) missing module named urllib.pathname2url - imported by urllib (conditional), PyInstaller.lib.modulegraph._compat (conditional) missing module named pyimod00_crypto_key - imported by PyInstaller.loader.pyimod02_archive (delayed, optional) missing module named thread - imported by numpy.core.arrayprint (conditional, optional), PyInstaller.loader.pyimod02_archive (conditional) missing module named 'macholib.dyld' - imported by PyInstaller.depend.bindepend (delayed) missing module named 'macholib.mach_o' - imported by PyInstaller.depend.bindepend (delayed) missing module named Crypto - imported by PyInstaller.building.makespec (delayed, conditional, optional) missing module named win32ctypes.core._time - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level) missing module named win32ctypes.core._system_information - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level) missing module named win32ctypes.core._resource - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level) missing module named win32ctypes.core._dll - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level) missing module named win32ctypes.core._common - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level), win32ctypes.pywin32.win32cred (top-level) missing module named win32ctypes.core._authentication - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32cred (top-level) missing module named cffi - imported by win32ctypes.core (optional) missing module named UserDict - imported by PyInstaller.compat (conditional), pytz.lazy (optional) missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level) missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level) missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level) missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level) missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level) missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level) missing module named pkg_resources.extern.packaging - imported by pkg_resources.extern (top-level), pkg_resources (top-level) missing module named pkg_resources.extern.appdirs - imported by pkg_resources.extern (top-level), pkg_resources (top-level) missing module named 'pkg_resources.extern.six.moves' - imported by pkg_resources (top-level), pkg_resources._vendor.packaging.requirements (top-level) missing module named pkg_resources.extern.six - imported by pkg_resources.extern (top-level), pkg_resources (top-level) missing module named 'multiprocessing.forking' - imported by c:\program files\python37\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_multiprocessing.py (optional) missing module named resource - imported by posix (top-level), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named posix - imported by os (conditional, optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional), E:\yxrj\dingzhi\cj\231.py (top-level) excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), PyInstaller.loader.pyimod02_archive (delayed, conditional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named _winreg - imported by platform (delayed, optional), numpy.distutils.cpuinfo (delayed, conditional, optional), requests.utils (delayed, conditional, optional), selenium.webdriver.firefox.firefox_binary (delayed, optional), E:\yxrj\dingzhi\cj\231.py (top-level), pkg_resources._vendor.appdirs (delayed) missing module named java - imported by platform (delayed), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named vms_lib - imported by platform (delayed, conditional, optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named termios - imported by tty (top-level), getpass (optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named urllib.getproxies_environment - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.proxy_bypass_environment - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.proxy_bypass - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.getproxies - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.unquote_plus - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.quote_plus - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.unquote - imported by urllib (conditional), requests.compat (conditional) missing module named urllib.urlencode - imported by urllib (optional), urllib3.packages.rfc3986.compat (optional), requests.compat (conditional) missing module named urllib.quote - imported by urllib (optional), urllib3.packages.rfc3986.compat (optional), requests.compat (conditional) missing module named grp - imported by shutil (optional), tarfile (optional), pathlib (delayed), distutils.archive_util (optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named 'org.python' - imported by pickle (optional), xml.sax (delayed, conditional), setuptools.sandbox (conditional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named org - imported by copy (optional), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), http.server (delayed, optional), webbrowser (delayed), pathlib (delayed, conditional, optional), distutils.util (delayed, conditional), distutils.archive_util (optional), netrc (delayed, conditional), getpass (delayed), E:\yxrj\dingzhi\cj\231.py (top-level) missing module named urllib2 - imported by numpy.lib._datasource (delayed, conditional), requests.compat (conditional), selenium.webdriver.common.utils (delayed, optional), selenium.webdriver.common.service (delayed, optional) missing module named urlparse - imported by numpy.lib._datasource (delayed, conditional), requests.compat (conditional), selenium.webdriver.remote.remote_connection (optional) runtime module named urllib3.packages.six.moves - imported by http.client (top-level), urllib3.connectionpool (top-level), urllib3.util.response (top-level), 'urllib3.packages.six.moves.urllib' (top-level), urllib3.response (top-level), urllib3.util.queue (top-level) missing module named 'OpenSSL.crypto' - imported by urllib3.contrib.pyopenssl (delayed) missing module named 'cryptography.x509' - imported by urllib3.contrib.pyopenssl (delayed, optional) missing module named 'cryptography.hazmat' - imported by pymysql._auth (optional), urllib3.contrib.pyopenssl (top-level) missing module named cryptography - imported by pymysql._auth (optional), urllib3.contrib.pyopenssl (top-level), requests (optional) missing module named OpenSSL - imported by urllib3.contrib.pyopenssl (top-level) missing module named 'backports.ssl_match_hostname' - imported by setuptools.ssl_support (optional), urllib3.packages.ssl_match_hostname (optional) missing module named brotli - imported by urllib3.util.request (optional), urllib3.response (optional) missing module named "'urllib3.packages.six.moves.urllib'.parse" - imported by urllib3.request (top-level), urllib3.poolmanager (top-level) missing module named Queue - imported by urllib3.util.queue (conditional) missing module named httplib - imported by selenium.webdriver.safari.webdriver (optional), selenium.webdriver.blackberry.webdriver (optional), selenium.webdriver.webkitgtk.webdriver (optional) missing module named cStringIO - imported by selenium.webdriver.firefox.firefox_profile (optional) missing module named copy_reg - imported by numpy.core (conditional), soupsieve.util (conditional), cStringIO (top-level) missing module named 'backports.functools_lru_cache' - imported by soupsieve.util (conditional) missing module named iconv_codec - imported by bs4.dammit (optional) missing module named cchardet - imported by bs4.dammit (optional) missing module named lxml - imported by bs4.builder._lxml (top-level) missing module named 'html5lib.treebuilders' - imported by bs4.builder._html5lib (optional) missing module named 'html5lib.constants' - imported by bs4.builder._html5lib (top-level) missing module named html5lib - imported by bs4.builder._html5lib (top-level) missing module named Cookie - imported by requests.compat (conditional) missing module named cookielib - imported by requests.compat (conditional) missing module named simplejson - imported by pandas.util._print_versions (delayed, conditional, optional), requests.compat (optional) missing module named socks - imported by urllib3.contrib.socks (optional) missing module named _dummy_threading - imported by dummy_threading (optional) missing module named ConfigParser - imported by numpy.distutils.system_info (conditional), numpy.distutils.npy_pkg_config (conditional), pymysql.optionfile (conditional) missing module named scipy - imported by numpy.testing._private.nosetester (delayed, conditional), pandas.core.missing (delayed) missing module named numexpr - imported by pandas.core.computation.expressions (conditional), pandas.core.computation.engines (delayed) missing module named 'scipy.stats' - imported by pandas.plotting._matplotlib.hist (delayed), pandas.plotting._matplotlib.misc (delayed, conditional), pandas.core.nanops (delayed, conditional) missing module named 'scipy.signal' - imported by pandas.core.window (delayed, conditional) missing module named commands - imported by numpy.distutils.cpuinfo (conditional) missing module named setuptools.extern.packaging - imported by setuptools.extern (top-level), setuptools.dist (top-level), setuptools.command.egg_info (top-level) missing module named 'setuptools.extern.six' - imported by setuptools (top-level), setuptools.extension (top-level) missing module named setuptools.extern.six.moves.filterfalse - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.msvc (top-level) missing module named setuptools.extern.six.moves.filter - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.ssl_support (top-level), setuptools.command.py36compat (top-level) missing module named _manylinux - imported by setuptools.pep425tags (delayed, optional) missing module named wincertstore - imported by setuptools.ssl_support (delayed, optional) missing module named backports - imported by setuptools.ssl_support (optional) missing module named 'setuptools._vendor.six.moves' - imported by 'setuptools._vendor.six.moves' (top-level) missing module named 'setuptools.extern.pyparsing' - imported by setuptools._vendor.packaging.requirements (top-level), setuptools._vendor.packaging.markers (top-level) missing module named 'setuptools.extern.packaging.version' - imported by setuptools.msvc (top-level) missing module named setuptools.extern.six.moves.map - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.package_index (top-level), setuptools.ssl_support (top-level), setuptools.command.egg_info (top-level), setuptools.namespaces (top-level) runtime module named setuptools.extern.six.moves - imported by setuptools.dist (top-level), setuptools.py33compat (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.command.setopt (top-level), setuptools.package_index (top-level), setuptools.ssl_support (top-level), setuptools.command.egg_info (top-level), setuptools.command.py36compat (top-level), setuptools.namespaces (top-level), setuptools.msvc (top-level), 'setuptools._vendor.six.moves' (top-level) missing module named setuptools.extern.six - imported by setuptools.extern (top-level), setuptools.monkey (top-level), setuptools.dist (top-level), setuptools.extern.six.moves (top-level), setuptools.py33compat (top-level), setuptools.config (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.py27compat (top-level), setuptools.package_index (top-level), setuptools.wheel (top-level), setuptools.command.egg_info (top-level), setuptools.command.sdist (top-level), setuptools.command.bdist_egg (top-level), setuptools.unicode_utils (top-level), setuptools.glob (top-level), setuptools.command.develop (top-level) missing module named 'numpy_distutils.cpuinfo' - imported by numpy.f2py.diagnose (delayed, conditional, optional) missing module named 'numpy_distutils.fcompiler' - imported by numpy.f2py.diagnose (delayed, conditional, optional) missing module named 'numpy_distutils.command' - imported by numpy.f2py.diagnose (delayed, conditional, optional) missing module named numpy_distutils - imported by numpy.f2py.diagnose (delayed, optional) missing module named 'nose.plugins' - imported by numpy.testing._private.noseclasses (top-level), numpy.testing._private.nosetester (delayed) missing module named numpy.core.number - imported by numpy.core (delayed), numpy.testing._private.utils (delayed) missing module named numpy.core.signbit - imported by numpy.core (delayed), numpy.testing._private.utils (delayed) missing module named numpy.core.float64 - imported by numpy.core (delayed), numpy.testing._private.utils (delayed) missing module named numpy.core.integer - imported by numpy.core (top-level), numpy.fft.helper (top-level) missing module named numpy.core.conjugate - imported by numpy.core (top-level), numpy.fft.pocketfft (top-level) missing module named numpy.core.sign - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.divide - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.object_ - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.geterrobj - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.sqrt - imported by numpy.core (top-level), numpy.linalg.linalg (top-level), numpy.fft.pocketfft (top-level) missing module named numpy.core.add - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.complexfloating - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.inexact - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.cdouble - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.csingle - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.double - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.single - imported by numpy.core (top-level), numpy.linalg.linalg (top-level) missing module named numpy.core.float32 - imported by numpy.core (top-level), numpy.testing._private.utils (top-level) missing module named numpy.core.intp - imported by numpy.core (top-level), numpy.testing._private.utils (top-level), numpy.linalg.linalg (top-level) missing module named numpy.eye - imported by numpy (delayed), numpy.core.numeric (delayed) missing module named dummy_thread - imported by numpy.core.arrayprint (conditional, optional) missing module named 'nose.util' - imported by numpy.testing._private.noseclasses (top-level) missing module named nose - imported by numpy.testing._private.utils (delayed, optional), numpy.testing._private.decorators (delayed), numpy.testing._private.noseclasses (top-level) missing module named win32pdh - imported by numpy.testing._private.utils (delayed, conditional) missing module named __svn_version__ - imported by numpy.f2py.__version__ (optional) missing module named numarray - imported by numpy.distutils.system_info (delayed, conditional, optional) missing module named Numeric - imported by numpy.distutils.system_info (delayed, conditional, optional) missing module named win32con - imported by distutils.msvccompiler (optional) missing module named _curses - imported by curses (top-level), curses.has_key (top-level) missing module named pytest - imported by numpy._pytesttester (delayed), pandas.util._tester (delayed, optional), pandas.util.testing (delayed, conditional, optional) missing module named future_builtins - imported by numpy.lib.npyio (conditional) missing module named cpickle - imported by numpy.compat.py3k (conditional) missing module named pickle5 - imported by numpy.compat.py3k (conditional, optional) missing module named numpy.histogramdd - imported by numpy (delayed), numpy.lib.twodim_base (delayed) missing module named numpy.lib.i0 - imported by numpy.lib (top-level), numpy.dual (top-level) missing module named 'scipy.sparse' - imported by pandas.core.sparse.scipy_sparse (delayed), pandas.core.arrays.sparse (delayed), pandas.core.dtypes.common (delayed, conditional, optional) missing module named botocore - imported by pandas.io.s3 (delayed) missing module named 'pyarrow.parquet' - imported by pandas.io.parquet (delayed) missing module named pyarrow - imported by pandas.io.feather_format (delayed) missing module named contextmanager - imported by dateutil.tz.tz (optional) runtime module named six.moves - imported by dateutil.tz.tz (top-level), dateutil.tz.win (top-level), dateutil.rrule (top-level) missing module named six.moves.range - imported by six.moves (top-level), dateutil.rrule (top-level) missing module named dateutil.tz.tzfile - imported by dateutil.tz (top-level), dateutil.zoneinfo (top-level) missing module named dateutil.tz.tzlocal - imported by dateutil.tz (top-level), dateutil.rrule (top-level) missing module named dateutil.tz.tzutc - imported by dateutil.tz (top-level), dateutil.rrule (top-level) missing module named PyQt4 - imported by pandas.io.clipboard.clipboards (delayed, optional), pandas.io.clipboard (delayed, conditional, optional) missing module named PyQt5 - imported by pandas.io.clipboard.clipboards (delayed, optional), pandas.io.clipboard (delayed, conditional, optional) missing module named qtpy - imported by pandas.io.clipboard.clipboards (delayed, optional), pandas.io.clipboard (delayed, conditional, optional) missing module named 'sqlalchemy.types' - imported by pandas.io.sql (delayed, conditional) missing module named 'sqlalchemy.schema' - imported by pandas.io.sql (delayed, conditional) missing module named sqlalchemy - imported by pandas.io.sql (delayed, conditional, optional) missing module named tables - imported by pandas.io.pytables (delayed, conditional) missing module named xlwt - imported by pandas.io.excel._xlwt (delayed) missing module named xlsxwriter - imported by pandas.io.excel._xlsxwriter (delayed) missing module named 'openpyxl.styles' - imported by pandas.io.excel._openpyxl (delayed) missing module named 'openpyxl.style' - imported by pandas.io.excel._openpyxl (delayed) missing module named openpyxl - imported by pandas.io.excel._openpyxl (delayed, conditional) missing module named xlrd - imported by pandas.io.excel._xlrd (delayed) missing module named 'odf.namespaces' - imported by pandas.io.excel._odfreader (delayed) missing module named 'odf.table' - imported by pandas.io.excel._odfreader (delayed) missing module named 'odf.opendocument' - imported by pandas.io.excel._odfreader (delayed) missing module named odf - imported by pandas.io.excel._odfreader (delayed) missing module named matplotlib - imported by pandas.plotting._matplotlib.boxplot (top-level), pandas.plotting._matplotlib.compat (delayed, optional), pandas.plotting._matplotlib.timeseries (delayed), pandas.plotting._matplotlib.core (delayed), pandas.io.formats.style (optional) missing module named 'matplotlib.pyplot' - imported by pandas.plotting._matplotlib.style (delayed), pandas.plotting._matplotlib.tools (delayed), pandas.plotting._matplotlib.core (delayed), pandas.plotting._matplotlib.timeseries (delayed), pandas.plotting._matplotlib.boxplot (delayed), pandas.plotting._matplotlib.hist (delayed), pandas.plotting._matplotlib.misc (delayed), pandas.plotting._matplotlib (delayed), pandas.io.formats.style (optional), pandas.util.testing (delayed) missing module named numpy.array - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.extras (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level) missing module named numpy.recarray - imported by numpy (top-level), numpy.ma.mrecords (top-level) missing module named numpy.ndarray - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.extras (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level), pandas.compat.numpy.function (top-level) missing module named numpy.dtype - imported by numpy (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level) missing module named numpy.bool_ - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.mrecords (top-level) missing module named 'matplotlib.ticker' - imported by pandas.plotting._matplotlib.converter (top-level), pandas.plotting._matplotlib.tools (top-level), pandas.plotting._matplotlib.core (delayed) missing module named 'matplotlib.table' - imported by pandas.plotting._matplotlib.tools (top-level) missing module named 'matplotlib.colors' - imported by pandas.plotting._matplotlib.style (top-level) missing module named 'matplotlib.cm' - imported by pandas.plotting._matplotlib.style (top-level) missing module named 'matplotlib.patches' - imported by pandas.plotting._matplotlib.misc (top-level) missing module named 'matplotlib.lines' - imported by pandas.plotting._matplotlib.misc (top-level) missing module named 'matplotlib.axes' - imported by pandas.plotting._matplotlib.core (delayed) missing module named 'matplotlib.units' - imported by pandas.plotting._matplotlib.converter (top-level) missing module named 'matplotlib.transforms' - imported by pandas.plotting._matplotlib.converter (top-level) missing module named 'matplotlib.dates' - imported by pandas.plotting._matplotlib.converter (top-level) missing module named numpy.expand_dims - imported by numpy (top-level), numpy.ma.core (top-level) missing module named numpy.iscomplexobj - imported by numpy (top-level), numpy.ma.core (top-level) missing module named numpy.amin - imported by numpy (top-level), numpy.ma.core (top-level) missing module named numpy.amax - imported by numpy (top-level), numpy.ma.core (top-level) missing module named 'IPython.core' - imported by pandas.io.formats.printing (delayed, conditional) missing module named IPython - imported by pandas.io.formats.printing (delayed) missing module named s3fs - imported by pandas.io.common (delayed, optional) missing module named sets - imported by pytz.tzinfo (optional) missing module named numpy.random.randn - imported by numpy.random (top-level), pandas.util.testing (top-level) missing module named numpy.random.rand - imported by numpy.random (top-level), pandas.util.testing (top-level) missing module named hypothesis - imported by pandas.util._tester (delayed, optional) missing module named 'lxml.etree' - imported by pandas.io.html (delayed) missing module named 'lxml.html' - imported by pandas.io.html (delayed)
keras中model.evaluate()报错:'numpy.float64' object is not iterable
``` x_train, x_test, y_train, y_test = train_test_split(x_data, y_data, test_size=0.25) mean = x_train.mean(axis=0) std = x_train.std(axis=0) train_data = (x_train - mean) / std test_data = (x_test - mean) / std model = Sequential([Dense(64, input_shape=(6,)), Activation('relu'), Dense(32), Activation('relu'), Dense(1)]) sgd = keras.optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) model.compile(loss='mean_squared_error', optimizer=sgd) k = model.fit [loss, sgd] = model.evaluate(test_data, y_test, verbose=1) ``` 最后一步不知道哪出了问题。。test_data, y_test都是dataframe啊 TypeError Traceback (most recent call last) <ipython-input-29-3b0767a3c446> in <module> ----> 1 [loss, mse] = model.evaluate(test_data, y_test, verbose=1) TypeError: 'numpy.float64' object is not iterable
关于归一化和numpy.log处理数据的疑问
在数据挖掘中, 有对数据进行归一化处理,比如StandardNormalization, 这种归一化处理的 好处是对异常的离散数值有很好的效果, 而numpy.log 可以对一些离散的异常数值有这种处理, 经过这种log处理后,得到的直方图更接近高斯分布, 我的问题是: 1. 我在网上看到一些大数据挖掘方面的资料,利用LogisticRegressor, 并没有对数据进行 归一化处理, 这种归一化是否不一定必须的 ? 2. 如果采用了 StandardNormalization 这种归一化处理,是否也相当于采用了Log处理的效果,而且数值被限定在更小的范围之内? 3. 数据挖掘中,如果用到 LogisticRegressor这种算法,是否直接对那些离散值直接进行StandardNormalization处理,不用采用Log处理?
python出现 'numpy.dtype' object has no attribute 'is_floating'
模型进行训练的时候在优化器运行部分出现了 'numpy.dtype' object has no attribute 'is_floating' ``` <ipython-input-1-12256e71d6bc> in <module> 260 print('\nPCC training') 261 start = time.time() --> 262 source_acc, target_acc = train_and_evaluate('pcc') 263 sio.savemat('PCC1.mat',{'a':target_y}) 264 end = time.time() <ipython-input-1-12256e71d6bc> in train_and_evaluate(training_mode, num_steps, verbose) 221 y = np.vstack([y0, y1]) 222 pred_loss, coral_loss, cycle_loss, total_loss, classify_labels, pred= loss_function(Fmodel,X,y,True) --> 223 pcc_train_op = tf.train.MomentumOptimizer(learning_rate, 0.9).minimize(lambda:total_loss) 224 #Evaluation 225 correct_label_pred = tf.equal(tf.argmax(classify_labels, 1),tf.argmax(pred_labels,1)) ~/anaconda3/envs/alex/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py in minimize(self, loss, global_step, var_list, gate_gradients, aggregation_method, colocate_gradients_with_ops, name, grad_loss) 401 aggregation_method=aggregation_method, 402 colocate_gradients_with_ops=colocate_gradients_with_ops, --> 403 grad_loss=grad_loss) 404 405 vars_with_grad = [v for g, v in grads_and_vars if g is not None] ~/anaconda3/envs/alex/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py in compute_gradients(self, loss, var_list, gate_gradients, aggregation_method, colocate_gradients_with_ops, grad_loss) 473 # to be executed. 474 with ops.control_dependencies([loss_value]): --> 475 grads = tape.gradient(loss_value, var_list, grad_loss) 476 return list(zip(grads, var_list)) 477 ~/anaconda3/envs/alex/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py in gradient(self, target, sources, output_gradients, unconnected_gradients) 948 flat_targets = [] 949 for t in nest.flatten(target): --> 950 if not t.dtype.is_floating: 951 logging.vlog( 952 logging.WARN, "The dtype of the target tensor must be " AttributeError: 'numpy.dtype' object has no attribute 'is_floating' ``` 一直解决不了
如何解决numpy.ndarray' object is not callable
我用python进行非线性规划时报错numpy.ndarray' object is not callable,有大佬可以帮忙解释一下吗 直到最后一句res=minimize。。。才报错,之前检查过都没有问题 ``` from scipy.optimize import minimize import numpy as np def fun(): v=lambda x:abs((x(1)+0*x(2)+0*x(3)+0*x(4)+0*x(5)+0*x(6)+0*x(7)+0*x(8)+0*x(9)+0*x(10)+0*x(11)+0*x(12)+0*x(13)+0*x(14))) return v def cons(): # d,e=args con=({'type':'eq','fun':lambda x: x(1)-(2171.4/0.85*x(2))}, {'type': 'eq', 'fun': lambda x: (x(5)*x(6)*89.496/6.28)-x(7)-x(8)}, {'type': 'eq', 'fun': lambda x: x(9)*x(10)-x(10)*x(11)-x(8)*x(11)}, {'type': 'eq', 'fun': lambda x: x(12) - x(13)+x(11)}, {'type': 'eq', 'fun': lambda x: x(10) - 12500*3.1415}, {'type': 'ineq', 'fun': lambda x: x(6) - x(14)}, {'type': 'ineq', 'fun': lambda x: x(3) - x(4)-2.45}, {'type': 'eq', 'fun': lambda x: x(14) - 12.14*3.1415}, {'type': 'ineq', 'fun': lambda x: x(4) - 2.45}, {'type': 'ineq', 'fun': lambda x: 97.55 - x(4)}, {'type': 'ineq', 'fun': lambda x: x(3) }, {'type': 'ineq', 'fun': lambda x: 95.1 - x(3)}, {'type': 'ineq', 'fun': lambda x: x(5)-2.45-x(4)}, {'type': 'ineq', 'fun': lambda x: 100-x(5)} ) return con a=fun() b=cons() # print(b) x0=np.asarray([3,4,3,2,3,4,3,2,3,4,3,2,3,2]) bounds=((0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None),(0,None)) res=minimize(a,x0,method='SLSQP',constraints=b,bounds=bounds) print(res) print(b) ```
Pycuda中gpuarray.to_gpu能向共享GPU内存中申请空间吗
GPU信息 ![GPU信息](https://img-ask.csdn.net/upload/202001/06/1578293738_135954.png) ![GPU信息](https://img-ask.csdn.net/upload/202001/06/1578293671_541491.png) --------------------------------------------- 运行如下代码 比较两个矩阵,取最大值为一个新矩阵 ``` import pycuda.driver as drv import pycuda.autoinit import numpy import numpy.linalg as la from pycuda import driver, compiler, gpuarray, tools from pycuda.compiler import SourceModule import os if (os.system("cl.exe")): os.environ['PATH'] += ';'+r"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\" if (os.system("cl.exe")): raise RuntimeError("cl.exe still not found, path probably incorrect") a = numpy.random.randint(0,3,(23600,26919)).astype(numpy.float32) b = numpy.random.randint(1,4,(23600,26919)).astype(numpy.float32) a_gpu = gpuarray.to_gpu(a) b_gpu = gpuarray.to_gpu(b) result_array_GPU = gpuarray.maximum(a_gpu,b_gpu) print(a_gpu.get()) print(b_gpu.get()) print(result_array_GPU,type(result_array_GPU.get())) ``` --- 出现错误 out of memory ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578293792_715378.png) --- 查看GPU性能,发现_**共享GPU内存**_还有空间,请问能利用这一块内存吗?如何利用这一块的内存呢 ![图片说明](https://img-ask.csdn.net/upload/202001/06/1578293948_284767.png) ---- 网上看说可以去BOIS总结去设置大小,也有的说当专有GPU内存不够会向共享自动申请 具体我还要怎么操作呢,还请不吝赐教
numpy.ndarray' object has no attribute 'show'
已安装:matplotlib,pyparsing,numpy,scipy 源代码: #!/usr/bin/env python # -*- coding:utf-8 -*- from PIL import Image from pylab import* im=array(Image.open('c:\\Python27\\tiananmen.jpg')) im.show() x=[100,100,400,400] y=[200,500,200,500] plot(x,y,'r*') #使用红色星状标记绘制点 plot(x[:2],y[:2])#绘制连接前两个点的线 title('Plotting:"tiananmen.jpg"') #添加标题
PYTHON使用statsmodels库失败
#代码 import numpy from statsmodels.tsa.stattools import adfuller adfuller(numpy.random.rand(100)) 提示的错误为 Warning (from warnings module): File "C:\Python27\lib\site-packages\statsmodels\compat\pandas.py", line 56 from pandas.core import datetools FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead.
请教朋友们,python中numpy.min(dataset[:,j]) 这句话是什么意思?
各位大神好,问题是这样的: 最近在看K-means聚类算法的python实现版本,看到了一个朋友写的程序,下面是选取数据集dataSet的k个初始中心的函数 ``` 各位大神好,问题是这样的: 最近在看K-means聚类算法的python实现版本,看到了一个朋友写的程序,下面是选取数据集dataSet的k个初始中心的函数 18 def randCent(dataSet, k): 19 n = shape(dataSet)[1] 20 centroids = mat(zeros((k,n))) 21 for j in range(n): 22 minJ = min(dataSet[:,j]) 23 rangeJ = float(max(array(dataSet)[:,j]) - minJ) 24 centroids[:,j] = minJ + rangeJ * random.rand(k,1) 25 return centroids 其中第22行没看明白minJ = min(dataSet[:,j]) dataSet是一个mat类型的numpy矩阵。 dataSet[:,j] 是什么意思啊?请教各位朋友,十分感谢 ``` 其中第22行没看明白minJ = min(dataSet[:,j]) dataSet是一个mat类型的numpy矩阵。 dataSet[:,j] 是什么意思啊?请教各位朋友,十分感谢
python自编逆矩阵遇到的奇怪问题
问题有点长,在这个博文有详细描述: https://blog.csdn.net/qq_42547404/article/details/103346884 就是自编逆矩阵代码结果,直接作为参数传入numpy.dot(),不能得到正确结果,必须要在作为参数传入numpy.dot()前,自己先运行一遍,才能得到正确结果,不知道是什么原因,盼高人指点一二
mxnet自动安装numpy 1.14.6,导致 importError(无法加载multiarray模块)
本人需要安装mxnet,而pip安装时,会自动卸载新版本numpy,重新安装1.14.6版本numpy,安装后numpy报错。于是本人卸载了mxnet和numpy进行测试。单独安装1.14.6版本numpy出错: windows平台,安装正常:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy==1.14.6 import numpy出错:![图片说明](https://img-ask.csdn.net/upload/201905/19/1558227199_638733.png) 新版本numpy正常安装后可以使用,但numpy 1.14.6出错。我的python是3.6版本的。请问这是什么原因?或者如何让mxnet不使用numpy 1.14.6?(经测试,安装1.16.3版本numpy后,mxnet也无法使用)
python中,opencv图片对象如何转化为f.read()这种类型的bytes
我已经知道从numpy.ndarray (图片)到字节流bytes: x = img.tobytes() 但是我现在想要的是将numpy.ndarray (图片)到f.read()这种类型的bytes ``` with open("1.png","rb") as f: bytes=f.read() ``` 如图, numpy.ndarray (图片)使用tobytes()到字节流bytes是上面的编码格式 f.read()是下面的字节编码方式 ![图片说明](https://img-ask.csdn.net/upload/201905/30/1559228339_868408.jpg)
安装了anaconda3,自带numpy库,但不能导入
ImportError Traceback (most recent call last) ~\AppData\Roaming\Python\Python36\site-packages\numpy\core\__init__.py in <module>() 15 try: ---> 16 from . import multiarray 17 except ImportError as exc: ImportError: cannot import name 'multiarray' During handling of the above exception, another exception occurred: ImportError Traceback (most recent call last) <ipython-input-1-5a0bd626bb1d> in <module>() ----> 1 import numpy ~\AppData\Roaming\Python\Python36\site-packages\numpy\__init__.py in <module>() 140 return loader(*packages, **options) 141 --> 142 from . import add_newdocs 143 __all__ = ['add_newdocs', 144 'ModuleDeprecationWarning', ~\AppData\Roaming\Python\Python36\site-packages\numpy\add_newdocs.py in <module>() 11 from __future__ import division, absolute_import, print_function 12 ---> 13 from numpy.lib import add_newdoc 14 15 ############################################################################### ~\AppData\Roaming\Python\Python36\site-packages\numpy\lib\__init__.py in <module>() 6 from numpy.version import version as __version__ 7 ----> 8 from .type_check import * 9 from .index_tricks import * 10 from .function_base import * ~\AppData\Roaming\Python\Python36\site-packages\numpy\lib\type_check.py in <module>() 9 'common_type'] 10 ---> 11 import numpy.core.numeric as _nx 12 from numpy.core.numeric import asarray, asanyarray, array, isnan, zeros 13 from .ufunclike import isneginf, isposinf ~\AppData\Roaming\Python\Python36\site-packages\numpy\core\__init__.py in <module>() 24 Original error was: %s 25 """ % (exc,) ---> 26 raise ImportError(msg) 27 28 for envkey in env_added: ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try `git clean -xdf` (removes all files not under version control). Otherwise reinstall numpy. Original error was: cannot import name 'multiarray' 问题补充:1.我已经在网上搜索了的问题,有人说需要卸载numpy库后重新装,试了但不管用,同时,我又重装了anaconda,也不管用。 2.我的电脑上还同时安装了独立的python3,python2。python3是默认系统。
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
JDK12 Collectors.teeing 你真的需要了解一下
前言 在 Java 12 里面有个非常好用但在官方 JEP 没有公布的功能,因为它只是 Collector 中的一个小改动,它的作用是 merge 两个 collector 的结果,这句话显得很抽象,老规矩,我们先来看个图(这真是一个不和谐的图????): 管道改造经常会用这个小东西,通常我们叫它「三通」,它的主要作用就是将 downstream1 和 downstre...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
【图解经典算法题】如何用一行代码解决约瑟夫环问题
约瑟夫环问题算是很经典的题了,估计大家都听说过,然后我就在一次笔试中遇到了,下面我就用 3 种方法来详细讲解一下这道题,最后一种方法学了之后保证让你可以让你装逼。 问题描述:编号为 1-N 的 N 个士兵围坐在一起形成一个圆圈,从编号为 1 的士兵开始依次报数(1,2,3…这样依次报),数到 m 的 士兵会被杀死出列,之后的士兵再从 1 开始报数。直到最后剩下一士兵,求这个士兵的编号。 1、方...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
GitHub标星近1万:只需5秒音源,这个网络就能实时“克隆”你的声音
作者 | Google团队 译者 | 凯隐 编辑 | Jane 出品 | AI科技大本营(ID:rgznai100) 本文中,Google 团队提出了一种文本语音合成(text to speech)神经系统,能通过少量样本学习到多个不同说话者(speaker)的语音特征,并合成他们的讲话音频。此外,对于训练时网络没有接触过的说话者,也能在不重新训练的情况下,仅通过未知...
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下...
【管理系统课程设计】美少女手把手教你后台管理
【文章后台管理系统】URL设计与建模分析+项目源码+运行界面 栏目管理、文章列表、用户管理、角色管理、权限管理模块(文章最后附有源码) 1. 这是一个什么系统? 1.1 学习后台管理系统的原因 随着时代的变迁,现如今各大云服务平台横空出世,市面上有许多如学生信息系统、图书阅读系统、停车场管理系统等的管理系统,而本人家里就有人在用烟草销售系统,直接在网上完成挑选、购买与提交收货点,方便又快捷。 试想,若没有烟草销售系统,本人家人想要购买烟草,还要独自前往药...
4G EPS 第四代移动通信系统
目录 文章目录目录4G 与 LTE/EPCLTE/EPC 的架构E-UTRANE-UTRAN 协议栈eNodeBEPCMMES-GWP-GWHSSLTE/EPC 协议栈概览 4G 与 LTE/EPC 4G,即第四代移动通信系统,提供了 3G 不能满足的无线网络宽带化,主要提供数据(上网)业务。而 LTE(Long Term Evolution,长期演进技术)是电信领域用于手机及数据终端的高速无线通...
相关热词 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片 c# 图片颜色调整 最快 c#多张图片上传 c#密封类与密封方法
立即提问