我无法安装 pyautogui 我已经尝试了一切,例如
pip3 install pillow
Run Code Online (Sandbox Code Playgroud)
还按照pyautogui 网站上的步骤进行操作。这是我在安装时收到的消息。
root@alex-Ai:/# pip3 install pyautogui
Collecting pyautogui
Using cached PyAutoGUI-0.9.36.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/Xlib/xauth.py", line 42, in __init__
raw = open(filename, 'rb').read()
FileNotFoundError: [Errno 2] No such file or directory: '/root/.Xauthority'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-mvyjt7lg/pyautogui/setup.py", line 6, in <module>
version=__import__('pyautogui').__version__,
File "/tmp/pip-build-mvyjt7lg/pyautogui/pyautogui/__init__.py", line 115, …Run Code Online (Sandbox Code Playgroud) 我对Mathematica很新,我试图找到只能使用数字0,1,2和3编写的大素数,这些数字中有一半以上必须为0.例如,100003符合条件.
如果使用"If"语句,我正在考虑使用Prime [n]函数,但我想知道是否有更有效的方法来解决这个问题.提前致谢.
我正在使用以下代码来匹配两个图像的冲浪特征,但无法裁剪和对齐图像。
原始图像-旋转图像和匹配图像如下。

我想像原始图像一样将旋转后的图像拉直,并裁剪出直线对齐的图像。我尝试了几何变换,但无法对齐图像。
import numpy
import cv2
############### Image Matching ###############
def match_images(img1, img2):
"""Given two images, returns the matches"""
detector = cv2.SURF(400, 5, 5)
matcher = cv2.BFMatcher(cv2.NORM_L2)
kp1, desc1 = detector.detectAndCompute(img1, None)
kp2, desc2 = detector.detectAndCompute(img2, None)
raw_matches = matcher.knnMatch(desc1, trainDescriptors = desc2, k = 2)
kp_pairs = filter_matches(kp1, kp2, raw_matches)
return kp_pairs
def filter_matches(kp1, kp2, matches, ratio = 0.75):
mkp1, mkp2 = [], []
for m in matches:
if len(m) == 2 and m[0].distance < m[1].distance * ratio: …Run Code Online (Sandbox Code Playgroud) 如果我有这样的目录结构:
\n\nsrc\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Commands.elm\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Decoders.elm\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Main.elm\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Messages.elm\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Models.elm\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Page\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Cats\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Main.elm\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Style.elm\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Pieces\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Main.elm\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Style.elm\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Players\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Main.elm\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Style.elm\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 ...\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Routing.elm\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Style\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Index.elm\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 MainCss.elm\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Main.elm\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Update.elm\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 View.elm\nRun Code Online (Sandbox Code Playgroud)\n\n我找到了一些说明如何从目录导入模块的示例,但找不到有关如何从子目录导入模块的示例。\n例如,如何Page/Cats/Main.elm …
我设法使TensorFlow(GPU)在Python 3.5.2中工作,但是当我尝试tensorboard从命令提示符启动时,出现以下错误:
C:\Users\Alex>tensorboard --logdir /tmp/data
Traceback (most recent call last):
File "c:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(__file__)])
File "c:\python35\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\python35\lib\site-packages\tensorflow\python\__init__.py", line 54, in <module>
from tensorflow.python import pywrap_tensorflow
File "c:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "c:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ImportError: …Run Code Online (Sandbox Code Playgroud) 我有一个Dask数据框,其中一列包含一个浮点数的numpy数组:
import dask.dataframe as dd
import pandas as pd
import numpy as np
df = dd.from_pandas(
pd.DataFrame(
{
'id':range(1, 6),
'vec':[np.array([1.0, 2.0, 3.0, 4.0, 5.0])] * 5
}), npartitions=1)
df.compute()
id vec
0 1 [1.0, 2.0, 3.0, 4.0, 5.0]
1 2 [1.0, 2.0, 3.0, 4.0, 5.0]
2 3 [1.0, 2.0, 3.0, 4.0, 5.0]
3 4 [1.0, 2.0, 3.0, 4.0, 5.0]
4 5 [1.0, 2.0, 3.0, 4.0, 5.0]
Run Code Online (Sandbox Code Playgroud)
如果我尝试将其写为实木复合地板,则会出现错误:
df.to_parquet('somefile')
....
Error converting column "vec" to bytes using encoding UTF8. Original …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 PowerShell 运行 python 脚本。在那个 python 脚本中,我尝试使用包含双引号和空格的命令行参数,但它无法正常工作。我怀疑这是 PowerShell 的问题。
(简化的)python 脚本如下所示:
import sys
print(sys.argv[1])
Run Code Online (Sandbox Code Playgroud)
以下调用和输出显示了问题
python script.py --arg=foo
--arg=foo
python script.py --arg='\"foo\"'
--arg="foo"
python script.py --arg='\"fo o\"'
--arg="fo
Run Code Online (Sandbox Code Playgroud)
但我最终需要的是
--arg="fo o"
Run Code Online (Sandbox Code Playgroud)
它会在空格之后去除所有内容。我在 Linux bash 中测试了相同的脚本(在 foo 周围使用双引号)。这似乎不是 python 问题,而是 PowerShell 问题,有人可以帮助我吗?最后我想要一个完整的 JSON-String 作为参数。
在下面的代码中,我将一个空数组传递给内部函数sum()和product()函数.
program test
implicit none
integer, allocatable :: A(:)
allocate( A( 0 ) )
print *, "sum = ", sum( A )
print *, "product = ", product( A )
end
Run Code Online (Sandbox Code Playgroud)
然后,我尝试过的所有编译器给出了相同的结果:
sum = 0
product = 1
Run Code Online (Sandbox Code Playgroud)
所以我想知道(1)是否允许将空数组传递给那些函数,以及(2)如果是这样,结果保证为0和1(根据Fortran标准).为了比较,一些其他语言(例如Python3)也给出0和1,其中(我猜)可能与极限sum( [1,2,...,n] )和product( [1,2,...,n] )to有关n -> 0.
>>> import numpy as np
>>> np.sum( [] )
0.0
>>> np.prod( [] )
1.0
Run Code Online (Sandbox Code Playgroud) scipy.signal.spectrogram计算信号的频谱图,但我看不到增加频谱图频率分辨率的选项.鉴于文档中提供的代码,如何实现?
from scipy import signal
import numpy as np
import matplotlib.pyplot as plt
fs = 10e3
N = 1e5
amp = 2 * np.sqrt(2)
noise_power = 0.01 * fs / 2
time = np.arange(N) / float(fs)
mod = 500*np.cos(2*np.pi*0.25*time)
carrier = amp * np.sin(2*np.pi*3e3*time + mod)
noise = np.random.normal(scale=np.sqrt(noise_power), size=time.shape)
noise *= np.exp(-time/5)
x = carrier + noise
f, t, Sxx = signal.spectrogram(x, fs)
plt.pcolormesh(t, f[0:10], Sxx[0:10,])
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.show()
Run Code Online (Sandbox Code Playgroud) 我正在做一个 PyCuda 代码,我想获得图形卡的属性(例如扭曲的大小、每块的最大线程数等)。
所以我去了这个页面:https : //documen.tician.de/pycuda/driver.html
我看到了这个:
然后我在我的代码中写了以下内容:
import time
import numpy as np
from pycuda import driver, compiler, gpuarray, tools
import math
# -- initialize the device
import pycuda.autoinit
print(pycuda.driver.device_attribute.WARP_SIZE)
Run Code Online (Sandbox Code Playgroud)
但打印返回:WARP_SIZE
事实上,他返回一个包含“WARP_SIZE”的 str 而不是代表经线大小的整数。
我究竟做错了什么 ?
我正在尝试从OCaml库中构建一个共享对象,我可以Python使用该cdll接口在其中运行ctypes.
有没有办法在OCaml工具链中引导一些东西来生成一个链接在其中的依赖项的共享对象?
我开始怀疑OCaml根本不支持我正在尝试做的事情.我想调用一个OCaml函数,但是它会产生某种结果并将控制权返回到调用它的位置.
这是我的OCaml库
(* foo.ml *)
let add x y = x + y
Run Code Online (Sandbox Code Playgroud)
我用来在OS X上编译它的命令.(使用.so而不是.dylib略微违反平台的命名约定,但ocamlopt只接受.o或的扩展名.so.)
$ ocamlopt -output-obj -fPIC -o foo.so foo.ml
Run Code Online (Sandbox Code Playgroud)
成功并产生foo.so.
这是我第一次尝试将共享对象加载到python程序(python 3.6).
# foo.py
import ctypes
lib = ctypes.cdll.LoadLibrary('./foo.so')
print("Loaded")
Run Code Online (Sandbox Code Playgroud)
运行时会产生以下错误
摘抄:
self._handle = _dlopen(self._name, mode)
OSError: dlopen(./foo.so, 6): Symbol not found: _caml_code_area_end
Run Code Online (Sandbox Code Playgroud)
完整错误:
Traceback (most recent call last):
File "foo.py", line 3, in <module>
lib = …Run Code Online (Sandbox Code Playgroud) 试图下载保存为~100MB HDF5文件的keras模型文件.
from google.colab import files
files.download('models/mlp_mnist_l.h5')
Run Code Online (Sandbox Code Playgroud)
但我一直得到以下ConnectionResetError
----------------------------------------
Exception happened during processing of request from ('::ffff:127.0.0.1', 43270, 0, 0)
Traceback (most recent call last):
File "/usr/lib/python3.6/socketserver.py", line 317, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python3.6/socketserver.py", line 348, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python3.6/socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.6/socketserver.py", line 696, in __init__
self.handle()
File "/usr/lib/python3.6/http/server.py", line 418, in handle
self.handle_one_request()
File "/usr/lib/python3.6/http/server.py", line 406, in handle_one_request
method()
File "/usr/lib/python3.6/http/server.py", line 639, in do_GET
self.copyfile(f, self.wfile)
File …Run Code Online (Sandbox Code Playgroud) python ×11
arrays ×1
cmd ×1
cuda ×1
dask ×1
elm ×1
fastparquet ×1
fortran ×1
image ×1
import ×1
json ×1
multi-module ×1
ocaml ×1
opencv ×1
pip ×1
powershell ×1
primes ×1
pyautogui ×1
pycuda ×1
scipy ×1
surf ×1
tensorboard ×1
tensorflow ×1
ubuntu ×1