小编Gre*_*ber的帖子

用于激活并保持打开 Virtualenv 的 Python 脚本

我需要一个python脚本来激活virtualenv,在virtualenv中运行另一个python程序,然后在第二个python程序关闭后关闭virutalenv。这是我的代码:

import os
import subprocess
from subprocess import Popen

activate_dir = "C:/Users/JohnDoe/theprogram/Scripts/"
os.chdir(activate_dir)
subprocess.Popen(["activate.bat"])

cal_dir = "C:/Users/JohnDoe/theprogram/"
os.chdir(cal_dir)
os.system('python program_file.py')
Run Code Online (Sandbox Code Playgroud)

但是,当此代码运行时,我收到一个导入错误,program_file这意味着 virtualenv 未激活。我怎样才能解决这个问题?

谢谢

编辑: 这是在 Windows 环境中。

python virtualenv python-3.x

6
推荐指数
1
解决办法
4648
查看次数

PyQt4 错误:确保您的 PATH 上有一个可用的 Qt qmake

我正在尝试使用 python 3.6.3 在 Windows 10 设备上运行 PyQt4。我sips已经在我的 python 目录中安装并构建了。但是,当我运行configure.py/configure-ng.pyPyQt4 文件夹中的文件时,出现以下错误:Error: Make sure you have a working Qt qmake on your PATH.

我不知道如何解决这个问题或是什么qmake。我感谢任何有关如何解决此问题的答案!

python qt qmake

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

Powershell - 通过 powershell 添加 ASP.NET 4.8

我正在使用此 powershell 脚本在 Windows 10 计算机上安装 IIS 服务器:

Set-ExecutionPolicy Unrestricted

Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment

Enable-WindowsOptionalFeature -Online -FeatureName NetFx4Extended-ASPNET45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility45

Enable-WindowsOptionalFeature -Online -FeatureName IIS-HealthAndDiagnostics
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpLogging
Enable-WindowsOptionalFeature -Online -FeatureName IIS-LoggingLibraries
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestMonitor
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Security
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestFiltering
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Performance
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerManagementTools
Enable-WindowsOptionalFeature -Online …
Run Code Online (Sandbox Code Playgroud)

iis powershell

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

EOFError:退出课堂内的输入

我有以下代码,我需要一次读取多个传感器.我已经设置了线程和多处理来为我完成这项任务.当线程和多重处理代码在主类之外时,它可以正常工作,但是类不能使用它所检索的数据.当我把mutlithreading代码insdie这个类时,我遇到了一个EOFError: Ran out of input错误.

这是代码:

import os
import multiprocessing
from multiprocessing import Process, Pool
import threading
import queue
import tkinter as tk
from tkinter import *
from tkinter import ttk
import time
import minimalmodbus
import serial
minimalmodbus.CLOSE_PORT_AFTER_EACH_CALL = True
THREAD_LOCK = threading.Lock()

class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)

        self.pack()

        self.first_gas_labelframe = LabelFrame(self, text="Gas 1", width=100)
        self.first_gas_labelframe.grid(row=0, column=0)

        self.value_label = Label(self.first_gas_labelframe, text="Value")
        self.value_label.grid(row=0, column=0)

        self.unit_label = Label(self.first_gas_labelframe, text="Unit")
        self.unit_label.grid(row=1, column=0)

        self.temp_label = Label(self.first_gas_labelframe, text="Temp")
        self.temp_label.grid(row=2, column=0)

        self.temp_label6 = …
Run Code Online (Sandbox Code Playgroud)

python multiprocessing python-multiprocessing

3
推荐指数
1
解决办法
5143
查看次数

附加到 Django 中的对象

我需要将信息附加到 Django 中的对象而不是更新它。我有这个数据库:

Database:
-----------------------
ColA  |  ColB
-----------------------
1     |  "Test string."
Run Code Online (Sandbox Code Playgroud)

以及更新的代码:

o = Model.objects.select_related().filter(ColA=1).update(
    ColB = "Entry 2")
Run Code Online (Sandbox Code Playgroud)

这将设置ColBEntry 2. 我希望能够追加而不是更新。有没有办法可以附加文本,以便ColB将其设置为"Test string. Entry 2."

python django

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