小编Adi*_*arg的帖子

遇到错误:设置Camera(Swift)时"将设备发现模式设置为DiscoveryMode_None"

这是我的代码设置一个简单的相机应用程序

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    let deviceSession = AVCaptureDeviceDiscoverySession(deviceTypes: [.builtInDualCamera, .builtInTelephotoCamera, .builtInWideAngleCamera], mediaType: AVMediaTypeVideo, position: .unspecified)
    for device in (deviceSession?.devices)!{
        if device.position == AVCaptureDevicePosition.front {
            do {
                currentDevice = device
                let input = try AVCaptureDeviceInput(device: device)
                if captureSession.canAddInput(input){
                    captureSession.addInput(input)

                    if captureSession.canAddOutput(photoOutput){
                        captureSession.addOutput(photoOutput)
                    }

                    if captureSession.canAddOutput(videoOutput){
                        captureSession.addOutput(videoOutput)
                        videoOutput.connection(withMediaType: AVMediaTypeVideo).isVideoMirrored = true
                    }

                    previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
                    previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
                    previewLayer.connection.videoOrientation = .portrait //Change orientation

                    cameraView.layer.addSublayer(previewLayer)
                    cameraView.addSubview(takePictureButton)
                    cameraView.addSubview(takeVideoButton)
                    cameraView.addSubview(saveVideoButton)


                    previewLayer.position = CGPoint(x: self.view.center.x, y: self.view.center.y)
                    previewLayer.bounds = CGRect(x: 100, …
Run Code Online (Sandbox Code Playgroud)

ios swift ios11

10
推荐指数
0
解决办法
2640
查看次数

运行 python 3.9.4 时,我无法导入 tkinter,但降级到 3.8.2 工作正常

我在 macOS Catalina 上运行 tcl 8.6.11,我使用安装了 python3 brew install python3

tclsh
% info patchlevel
8.6.11
Run Code Online (Sandbox Code Playgroud)

当前版本的python 3.9.4

python3 --version 
Python 3.9.4 

>>> import tkinter 
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
Run Code Online (Sandbox Code Playgroud)

降级到 3.8.2

python3 --version 
Python 3.8.2

>>> import tkinter
>>> 
Run Code Online (Sandbox Code Playgroud)

不确定是什么原因造成的,任何见解将不胜感激

python tkinter python-3.x python-3.8 python-3.9

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

标签 统计

ios ×1

ios11 ×1

python ×1

python-3.8 ×1

python-3.9 ×1

python-3.x ×1

swift ×1

tkinter ×1