我在 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
我有这些图片
我想删除背景中的文本。只有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) 我有一个非常高分辨率(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版本:3.10
\n我试图使用以下 pip 命令安装freegames python 包
\nC:\\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\nRun Code Online (Sandbox Code Playgroud)\n但是在我的 python 环境中导入相同的内容时,我收到了这个错误
\nC:\\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) 所以我按照教程连接到我的 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)
我该如何解决?或者有没有其他方法可以实现相同的目标?
我使用的是引导卡,我需要将卡中的所有图像设置为具有相同的大小。虽然有多种方法可以实现相同的目标,但我使用这种样式来实现相同的目标。
检查下面的图像样式
<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 对象中编写的,因此具有两个名称的属性(例如背景颜色)必须使用驼峰式语法编写:
我试图从驱动器加载文件夹,但加载时出现错误
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) 我试图在我的应用程序中使用自动完成功能。但是安装自动完成后,它将引发错误
"couldn't find file 'autocomplete-rails' with type 'application/javascript' "
Sprockets::FileNotFound in Spree::Home#index
Run Code Online (Sandbox Code Playgroud)
请指导我如何在我的应用程序中使用自动完成功能。
我试图连接到在远程服务器上运行的 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) 我在 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 ×7
opencv ×2
bootstrap-5 ×1
celery ×1
css ×1
directory ×1
django ×1
drive ×1
image ×1
imshow ×1
jsx ×1
jupyter ×1
localhost ×1
matplotlib ×1
mount ×1
networking ×1
pip ×1
python-3.10 ×1
rabbitmq ×1
reactjs ×1
server ×1
ssh ×1
virtualenv ×1
windows ×1