小编Him*_*dar的帖子

VS代码终端:无法加载Activate.ps1,因为在此系统上禁用运行脚本

我在 python 中创建了一个虚拟环境,现在在 vscode 中从命令行激活相同的虚拟环境时出现错误

PS C:\Users\hpoddar\Desktop\WebDev\ReactComplete\DjangoReact\ArticlesApp\APIProject> ..\venv\scripts\activate    
..\venv\scripts\activate : File C:\Users\hpoddar\Desktop\WebDev\ReactComplete\DjangoReact\ArticlesApp\venv\scripts\Activate.ps1 cannot be loaded because running 
scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ ..\venv\scripts\activate
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
Run Code Online (Sandbox Code Playgroud)

这是我的项目结构

在此输入图像描述

但是,如果我从命令行激活相同的功能,它就可以正常工作,不会出现任何错误。

Python版本:3.9.2

在此输入图像描述

python command-prompt virtualenv unauthorizedaccessexcepti visual-studio-code

22
推荐指数
1
解决办法
5万
查看次数

使用 OpenCV 的图像处理去除图像中的背景文本和噪声

我有这些图片

在此处输入图片说明

在此处输入图片说明

我想删除背景中的文本。只有captcha characters应该保留(即 K6PwKA、YabVzu)。任务是稍后使用 tesseract 识别这些字符。

这是我尝试过的,但它并没有给出很好的准确性。

import cv2
import pytesseract

pytesseract.pytesseract.tesseract_cmd = r"C:\Users\HPO2KOR\AppData\Local\Tesseract-OCR\tesseract.exe"
img = cv2.imread("untitled.png")
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray_filtered = cv2.inRange(gray_image, 0, 75)
cv2.imwrite("cleaned.png", gray_filtered)
Run Code Online (Sandbox Code Playgroud)

我该如何改进?

注意: 我尝试了针对这个问题提出的所有建议,但没有一个对我有用。

编辑: 根据 Elias 的说法,我尝试使用 photoshop 找到验证码文本的颜色,方法是将其转换为灰度,结果介于 [100, 105] 之间。然后我根据这个范围对图像进行阈值处理。但是我得到的结果并没有从tesseract给出令人满意的结果。

gray_filtered = cv2.inRange(gray_image, 100, 105)
cv2.imwrite("cleaned.png", gray_filtered)
gray_inv = ~gray_filtered
cv2.imwrite("cleaned.png", gray_inv)
data = pytesseract.image_to_string(gray_inv, lang='eng')
Run Code Online (Sandbox Code Playgroud)

输出 :

'KEP wKA'
Run Code Online (Sandbox Code Playgroud)

结果 :

在此处输入图片说明

编辑 2:

def get_text(img_name):
    lower = (100, 100, 100)
    upper = (104, 104, 104) 
    img = …
Run Code Online (Sandbox Code Playgroud)

python opencv image image-processing computer-vision

10
推荐指数
2
解决办法
7520
查看次数

在 jupyter 笔记本中以原始分辨率显示图像

我有一个非常高分辨率(3311, 4681, 3)的图像,我想使用 opencv 在我的 jupyter 笔记本中显示它,但正如其他答案所述,它不可能cv2.imshow在 jupyter 笔记本中使用,所以我曾经plt.imshow这样做,但问题是如果我想显示更大的图像,我必须定义Fig_size参数。如何在 jupyter 笔记本中以其原始分辨率读取图像,或者是否可以在另一个窗口中打开图像?

这是我尝试过的:

import cv2
from matplotlib import pyplot as plt
%matplotlib inline

img = cv2.imread(r"0261b27431-07_D_01.jpg")
plt.figure(figsize= (20,20))
plt.imshow(img)
plt.show()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

所以基本上我希望我的图像在 jupyter 笔记本或另一个窗口中以其原始分辨率显示。

python opencv matplotlib imshow jupyter-notebook

9
推荐指数
1
解决办法
8204
查看次数

无法导入 freegames python 包:AttributeError:模块“集合”没有属性“序列”

Python版本:3.10

\n

我试图使用以下 pip 命令安装freegames python 包

\n
C:\\Users\\praty>pip install freegames\nDefaulting to user installation because normal site-packages is not writeable\nCollecting freegames\n  Downloading freegames-2.3.2-py2.py3-none-any.whl (108 kB)\n     |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 108 kB 504 kB/s\nInstalling collected packages: freegames\nSuccessfully installed freegames-2.3.2\n
Run Code Online (Sandbox Code Playgroud)\n

但是在我的 python 环境中导入相同的内容时,我收到了这个错误

\n
C:\\Users\\praty>python\nPython 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32\nType "help", "copyright", "credits" or "license" for more information.\n>>> import freegames\nTraceback (most recent call last):\n  File "<stdin>", line 1, in <module>\n  File "C:\\Users\\praty\\AppData\\Roaming\\Python\\Python310\\site-packages\\freegames\\_init_.py", line 61, in …
Run Code Online (Sandbox Code Playgroud)

python pip attributeerror python-3.10

9
推荐指数
1
解决办法
1万
查看次数

CreateProcessW failed error:2 ssh_askpass: posix_spawn: No such file or directory 主机密钥验证失败,远程服务器上的 jupyter notebook

所以我按照教程连接到我的 jupyter notebook,它在我的远程服务器上运行,这样我就可以在我的本地 Windows 机器上访问它。

这些是我遵循的步骤。

在我的远程服务器上:

jupyter notebook --no-browser --port=8889
Run Code Online (Sandbox Code Playgroud)

然后在我的本地机器上

ssh -N -f -L localhost:8888:localhost:8889 *******@**********.de.bosch.com
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误

CreateProcessW failed error:2
ssh_askpass: posix_spawn: No such file or directory
Host key verification failed.
Run Code Online (Sandbox Code Playgroud)

我该如何解决?或者有没有其他方法可以实现相同的目标?

python localhost remote-server jupyter jupyter-notebook

8
推荐指数
1
解决办法
1万
查看次数

React JSX 无法识别图像样式属性中的对象适合度

我使用的是引导卡,我需要将卡中的所有图像设置为具有相同的大小。虽然有多种方法可以实现相同的目标,但我使用这种样式来实现相同的目标。

检查下面的图像样式

<div className="card " style={{width: "18rem"}}>
    <img src={imageUrl} className="card-img-top" style={{width: "100%", height: "40vh", object-fit: contain}} alt="..."/>
    <div className="card-body">
        <h5 className="card-title">{title}...</h5>
        <p className="card-text">{description}...</p>
        <a href={newsUrl} target="_blank" className="btn btn-sm rounded-pill btn-primary">Read More</a>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

但是我收到错误

SyntaxError:C:\Users\hpoddar\Desktop\WebDev\ReactComplete\newsapp\src\components\NewsItem.js:意外的标记,应为“,”(10:110)

在此输入图像描述

如果我删除 object-fit 属性,一切都会正常工作并符合预期。蜿蜒的线消失了。

我该如何解决同样的问题?

Bootstrap version : 5.1
react: 17.0.2
react-dom: 17.0.2
react-scripts: 4.0.3
web-vitals: 1.1.2
Run Code Online (Sandbox Code Playgroud)

编辑:我有这个疑问为什么 object-fit 被用作 objectFit,安德鲁在评论中回答了这个问题。

由于内联 CSS 是在 JavaScript 对象中编写的,因此具有两个名称的属性(例如背景颜色)必须使用驼峰式语法编写:

css jsx twitter-bootstrap reactjs bootstrap-5

7
推荐指数
1
解决办法
1万
查看次数

如何仅加载 google colab 上的特定文件夹?

我试图从驱动器加载文件夹,但加载时出现错误

ValueError                                Traceback (most recent call last)
<ipython-input-3-a977da366961> in <module>()
      1 from google.colab import drive
----> 2 drive.mount('content/gdrive/My Drive/kaggle')

/usr/local/lib/python3.6/dist-packages/google/colab/drive.py in mount(mountpoint, force_remount, timeout_ms)
     69 
     70   if ' ' in mountpoint:
---> 71     raise ValueError('Mountpoint must not contain a space.')
     72 
     73   mountpoint = _os.path.expanduser(mountpoint)

ValueError: Mountpoint must not contain a space.
Run Code Online (Sandbox Code Playgroud)

我该如何摆脱这个错误。这是我尝试过的:

from google.colab import drive
drive.mount('content/gdrive/My Drive/kaggle')
Run Code Online (Sandbox Code Playgroud)

python directory mount drive google-colaboratory

5
推荐指数
1
解决办法
1万
查看次数

jQuery自动完成gem在应用程序中不起作用

我试图在我的应用程序中使用自动完成功能。但是安装自动完成后,它将引发错误

"couldn't find file 'autocomplete-rails' with type 'application/javascript' "
Sprockets::FileNotFound in Spree::Home#index
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

请指导我如何在我的应用程序中使用自动完成功能。

ruby-on-rails

5
推荐指数
0
解决办法
61
查看次数

输入时的 MAC 已损坏。ssh_dispatch_run_fatal:消息身份验证代码不正确无法在远程服务器上ssh jupyter笔记本

我试图连接到在远程服务器上运行的 jupyter 笔记本,以便我可以在本地 Windows 计算机上访问它。

这些是我遵循的步骤。

在我的远程服务器上:

jupyter notebook --no-browser --port=8889
Run Code Online (Sandbox Code Playgroud)

然后在我本地的 Windows 机器上

ssh -N -f -L localhost:8888:localhost:8889 *******@**********.de.bosch.com
Run Code Online (Sandbox Code Playgroud)

但我收到错误

C:\>ssh -N -f -L localhost:8888:localhost:8889 *******@**********.de.bosch.com
Corrupted MAC on input.
ssh_dispatch_run_fatal: Connection to 10.82.134.38 port 22: message authentication code incorrect
Run Code Online (Sandbox Code Playgroud)

然而,当我尝试在 Microsoft Ubuntu WSL 上做同样的事情时。我能够成功连接,然后我可以通过输入jupyter notebookcmd来连接。

ssh -N -f -L localhost:8888:localhost:8889 *****@*******.de.bosch.com
The authenticity of host '*****@*******.de.bosch.com (10.82.134.38)' can't be established.
ECDSA key fingerprint is SHA256:EMneQnZfl3uyH0xeH+LPnkib4v7lF24qdx5C1QnXkxI.
Are you sure you want to continue connecting (yes/no)? yes
Warning: …
Run Code Online (Sandbox Code Playgroud)

windows ssh networking remote-access server

5
推荐指数
1
解决办法
2万
查看次数

将任务添加到 RabbitMQ 消息队列时 Django celery 错误:AttributeError: 'ChannelPromise' 对象没有属性 '__value__'

我在 digitalocean 上设置了 celery、rabbitmq 和 django Web 服务器。RabbitMQ 在另一台服务器上运行,我的 Django 应用程序未在该服务器上运行。当我尝试使用延迟将任务添加到队列时,出现错误

AttributeError:“ChannelPromise”对象没有属性“ value

从 django shell 中,我将任务添加到我的消息队列中。

python3 管理.py shell

Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from app1.tasks import add
>>> add.delay(5, 6)
Run Code Online (Sandbox Code Playgroud)

但出现错误

Traceback (most recent call last):
  File "/etc/myprojectenv/lib/python3.8/site-packages/kombu/utils/functional.py", line 30, in __call__
    return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'

During handling of the above exception, another exception occurred: …
Run Code Online (Sandbox Code Playgroud)

python django rabbitmq system-design celery

5
推荐指数
1
解决办法
4580
查看次数