manim does not create an output file - python

If I run
python -m manimlib scene.py ket_bra
My scene renders fine into the interactive viewer, but I don't get any output file, the terminal prints the following
ManimGL v1.6.1
[13:55:48] INFO Using the default configuration file, which you can modify in `c:\users\miika\manim\manimlib\default_config.yml` config.py:323
INFO If you want to create a local configuration file, you can create a file named `custom_config.yml`, or run `manimgl --config` config.py:324
WARNING You may be using Windows platform and have not specified the path of `temporary_storage`, which may cause OSError. So it is recommended to specify the `temporary_storage` in the config file config.py:290
(.yml)
(process:3548): GLib-GIO-WARNING **: 13:55:49.613: Unexpectedly, UWP app `Clipchamp.Clipchamp_2.3.0.0_neutral__yxz26nhyzhsrt' (AUMId `Clipchamp.Clipchamp_yxz26nhyzhsrt!App') supports 46 extensions but has no verbs
If I add the parameter -p to the command then the interactive window remains blank and doesn't render the scene and in no case do I get an output file which is what I'm looking for and the terminal output is the same as before. Also if it's of note the background is grey, even tho it appears to be black in all samples that I can find. I have absolutely no idea what's going on as I can't find anybody else with a similar issue. I'm using windows 10 and v1.6.1 of 3b1b manim. The scene in this case is as follows (though this issue appears regardless of what the scene is)
from manimlib import *
class ket_bra(Scene):
def construct(self):
ket_q0 = Tex(r"|q_0\rangle")
ket_0 = Tex(r"|0\rangle")
ket_1 = Tex(r"|1\rangle")
ket_0_v2 = Tex(r"|0\rangle")
ket_1_v2 = Tex(r"|1\rangle")
ket_0_v3 = Tex(r"""|0\rangle=\begin{pmatrix}
1\\
0
\end{pmatrix}""")
ket_1_v3 = Tex(r"""|1\rangle=\begin{pmatrix}
0\\
1
\end{pmatrix}""")
bra_kets = VGroup(ket_q0, ket_0, ket_1).arrange(RIGHT, buff=1)
v_bra_kets = VGroup(ket_0_v2, ket_1_v2).arrange(RIGHT, buff=1.5)
bra_kets_def = VGroup(ket_0_v3, ket_1_v3).arrange(RIGHT, buff=1.5)
self.play(Write(ket_q0), Write(ket_0), Write(ket_1))
self.wait(0.5)
self.play(FadeOut(ket_q0))
self.play(Transform(ket_0, ket_0_v2), Transform(ket_1, ket_1_v2))
self.wait(1)
self.play(Transform(ket_0, ket_0_v3), Transform(ket_1, ket_1_v3))

Well I fixed the problem, without fixing the problem, I just switched to the community edition of manim and it works exactly as intended, so if you encounter the same problem and you're using 3b1b manim version, I reccomend just switching to the community version of manim, they are mostly functionally equivalent, but the community edition appears to be less buggy at least for me. Here's a super easy installation guide for it https://docs.manim.community/en/stable/installation/windows.html
However, I won't mark this as the best answer, because I didn't really solve the problem, and I still get the following warning and have no idea what it is. However, it appears to not affect functionality so it's fine, lol.

Windows Solution
Create TempLatex directory in C drive
Find manimlib/default_config.yml in the manim (manimgl version) directory and open it with a text editor
Modify line 18: before: temporary_storage: "" after: temporary_storage: "C:/TempLatex "
Save
From:
https://github.com/3b1b/manim/issues/1661#issuecomment-996575974

Related

2nd int-casting input-taking variables causes problem

I'm working in PyCharm. I haven't been programming for a few months and when I came back I saw a problem.
There are 2 user-input-taking variables, input is converted to int.
height = int(input())
width = int(input())
(it's literally entire code, there's nothing more)
When I run the program and give the 1st integer value, it's still fine, but the 2nd integer causes the following error:
ValueError: invalid literal for int() with base 10: ''
For some reason, it is "ValueError", though I just give it integer value (see screen at the end) and it seems to indicate that I gave it an empty string which is untrue (again, see the screen - I even marked the values I had given; in this case it was 4 and 5).
If I put some code between the 2 variables, like below, the problem doesn't appear:
height = int(input())
print(height)
width = int(input())
Also note that if it's just one variable, the problem doesn't appear.
And the problem appears only in PyCharm, I did the same in VSCode and everything worked properly. I also reinstalled PyCharm to check if it helps, but it didn't.
I suppose the problem is related to PyCharm, but since hard reinstall (deleting all that Revo Uninstaller found being related to PyCharm) didn't help I have no more ideas...
Visualization:
error
Please, check your python --version in virtual environment (it should be python 3.x)
I just ran the code myself (with a few amendments just to see the prompts) and it runs completely fine in my vs code even before my prompt amendments.
height = int(input("Input Height: "))
width = int(input("Input Width: "))# Write your code here :-)
area = height * width
print(area)
I would suggest checking you have the most update version of python and that everything is configured correctly on your machine.
Also it might help to re-save the file and re run.
It seems to be a known issue which will be fixed in the next PyCharm version.
See: https://youtrack.jetbrains.com/issue/PY-54238/STDIN-is-lost-for-a-second-input-call
As suggested by the support current workaround is to enable the "Emulate terminal in output console".

How to change username of job in print queue using python & win32print

I am trying to change the user of a print job in the queue, as I want to create it on a service account but send the job to another users follow-me printing queue. I'm using the win32 module in python. Here is an example of my code:
from win32 import win32print
JOB_INFO_LEVEL = 2
pclExample = open("sample.pcl")
printer_name = win32print.GetDefaultPrinter()
hPrinter = win32print.OpenPrinter(printer_name)
try:
jobID = win32print.StartDocPrinter(hPrinter, 1, ("PCL Data test", None, "RAW"))
# Here we try to change the user by extracting the job and then setting it again
jobInfoDict = win32print.GetJob(hPrinter, jobID , JOB_INFO_LEVEL )
jobInfoDict["pUserName"] = "exampleUser"
win32print.SetJob(hPrinter, jobID , JOB_INFO_LEVEL , jobInfoDict , win32print.JOB_CONTROL_RESUME )
try:
win32print.StartPagePrinter(hPrinter)
win32print.WritePrinter(hPrinter, pclExample)
win32print.EndPagePrinter(hPrinter)
finally:
win32print.EndDocPrinter(hPrinter)
finally:
win32print.ClosePrinter(hPrinter)
The problem is I get an error at the win32print.SetJob() line. If JOB_INFO_LEVEL is set to 1, then I get the following error:
(1804, 'SetJob', 'The specified datatype is invalid.')
This is a known bug to do with how the C++ works in the background (Issue here).
If JOB_INFO_LEVEL is set to 2, then I get the following error:
(1798, 'SetJob', 'The print processor is unknown.')
However, this is the processor that came from win32print.GetJob(). Without trying to change the user this prints fine, so I'm not sure what is wrong.
Any help would be hugely appreciated! :)
EDIT:
Using Python 3.8.5 and Pywin32 303
At the beginning I thought it was a misunderstanding (I was also a bit skeptical about the bug report), mainly because of the following paragraph (which apparently seems to be wrong) from [MS.Docs]: SetJob function (emphasis is mine):
The following members of a JOB_INFO_1, JOB_INFO_2, or JOB_INFO_4 structure are ignored on a call to SetJob: JobId, pPrinterName, pMachineName, pUserName, pDrivername, Size, Submitted, Time, and TotalPages.
But I did some tests and ran into the problem. The problem is as described in the bug: filling JOB_INFO_* string members (which are LPTSTRs) with char* data.
Submitted [GitHub]: mhammond/pywin32 - Fix: win32print.SetJob sending ANSI to UNICODE API (and none of the 2 errors pops up). It was merged to main on 220331.
When testing the fix, I was able to change various properties of an existing job, I was amazed that it didn't have to be valid data (like below), I'm a bit curious to see what would happen when the job would be executed (as now I don't have a connection to a printer):
Change pUserName to str(random.randint(0, 10000)) to make sure it changes on each script run (PrintScreens taken separately and assembled in Paint):
Ways to go further:
Wait for a new PyWin32 version (containing this fix) to be released. This is the recommended approach, but it will also take more time (and it's unclear when it will happen)
Get the sources, either:
from main
from b303 (last stable branch), and apply the (above) patch(1)
build the module (.pyd) and copy it in the PyWin32's site-packages directory on your Python installation(s). Faster, but it requires some deeper knowledge, and maintenance might become a nightmare
Footnotes
#1: Check [SO]: Run / Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (#CristiFati's answer) (Patching UTRunner section) for how to apply patches (on Win).

python WMI screen brightness adjuster gets error 0x8004100c

I'm currently working on a script that creates a tray icon that allows the user to adjust screen brightness through menu options. The source code, written in python 3.6.8, can be found as a paste HERE. There seems to be an error message coming up when trying to select one of the brightness options, seen HERE. I did some reading and found that the error I'm getting (0x8004100c) refers to a feature or operation not being supported. Are there any workarounds available for this?
Thank you in advance.
code: https://pastebin.com/sLbyE9yb
error: https://pastebin.com/Xs7wHk73
WMI error reference: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants
gist: https://gist.github.com/imri0t/12e768e3d7e08734b85ae532d56090e1
(also if anyone can let me know if there's a way to keep the script from dying after an action is made it would be appreciated)
modules needed: pip install infi.systray / pip install wmi
code snip that I believe produces the error:
from infi.systray import SysTrayIcon
import wmi
def brightness_50(systray):
'''brightness: 50%'''
b = 50
c = wmi.WMI(namespace='root\\wmi')
br = c.WmiMonitorBrightnessMethods()[0]
br.WmiSetBrightness(3, b) #b will be a precentage / 100
menu = (("brightness: 100%", None, brightness_50))
systray = SysTrayIcon("icon.ico", "brightness", menu)
systray.start()

Why python doesn't see the members of quantumCircuit class qiskit

I`m trying to learn the programming on quantum computers.
I have installed qiskit in VS Code (all qiskit extentions available in VS Code market) , python compilator (from Vs Code market "Python" and "Python for VSCode"). I have set up my qikit API for correct working
When I run the exemple I get erros: "Instance of 'QuantumCircuit' has no 'h' member"
What shoud I do?
The code:
from qiskit import ClassicalRegister, QuantumRegister
from qiskit import QuantumCircuit, execute
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q, c)
job_sim = execute(qc, 'local_qasm_simulator')
sim_result = job_sim.result()
print(sim_result.get_counts(qc))
========================
The same error after adding comment # pylint: disable=no-member
The errors in question are coming from pylint, a linter, not from python itself. While pylint is pretty clever, some constructs (particularly those involving dynamically-added properties) are beyond its ability to understand. When you encounter situations like this, the best course of action is twofold:
Check the docs, code, etc. to make absolutely sure the code that you've written is right (i.e. verify that the linter result is a false positive)
Tell the linter that you know what you're doing and it should ignore the false positive
user2357112 took care of the first step in the comments above, demonstrating that the property gets dynamically set by another part of the library.
The second step can be accomplished for pylint by adding a comment after each of the offending lines telling it to turn of that particular check for that particular line:
qc.h(q[0]) # pylint: disable=no-member

PyInstaller very big file size

I've made simple code editor using wxPython. File size (python files) is 1.3 KB. But when I create executable using PyInstaller, I get 30 MB file! Is there a way to decrease file size? Btw, I am not importing whole wx library, only components I need (ex from wx import Frame).
Using Linux, Fedora 18 64bit.
wxPython is a big library so when you create an executable, they tend to end up being between 20 and 30 MB. Also note that Python itself is kind of bulky because Python is an interpreted language. So you are also including the Python interpreter when you create the exe.
With py2exe, I have gotten the executable below 10 MB, but it's a pain and doesn't work for all projects. It really depends on what else you are using. You can read about my adventures with py2exe here.
The other way to get it smaller is to use a compression program. That sometimes works and sometimes doesn't.
You can also tell most of these binary creation tools to exclude items. You can try that too.
I shipped a fairly simple wxPython app and it ended up being ~9.8MB.
If you utilize the ArchiveViewer.py script that's part of PyInstaller you can determine what's taking up so much space.
This was with python 2.7.5, without UPX, and excluding these modules:
excludesPassedToAnalysis = ['ssl',
'_ssl',
# coverage uses _socket. :(
#'_socket',
'select',
'pywin',
'unittest',
'win32ui',
'bz2',
'doctest',
'os2emxpath',
'servicemanager',
'xml.parsers.expat',
'sitecustomize',
'tarflie',
'email',
'urllib',
'urllib2',
# This exclude isn't optional in order to get pubsub working
# correctly in wxPython 2.9.3 or later.
'wx.lib.pubsub.autosetuppubsubv1']
# These are removed from a.pure after the Analysis object is created.
excludeEncodings = \
['encodings.base_64_codec',
'encodings.big5',
'encodings.big5hkscs',
'encodings.bz2_codec',
'encodings.cp037',
'encodings.cp1006',
'encodings.cp1026',
'encodings.cp1140',
'encodings.cp1258',
'encodings.cp424',
'encodings.cp437',
'encodings.cp500',
'encodings.cp720',
'encodings.cp737',
'encodings.cp775',
'encodings.cp850',
'encodings.cp852',
'encodings.cp855',
'encodings.cp856',
'encodings.cp857',
'encodings.cp858',
'encodings.cp860',
'encodings.cp861',
'encodings.cp862',
'encodings.cp863',
'encodings.cp864',
'encodings.cp865',
'encodings.cp866',
'encodings.cp869',
'encodings.cp874',
'encodings.cp875',
'encodings.cp932',
'encodings.cp949',
'encodings.cp950',
'encodings.euc_jis_2004',
'encodings.euc_jisx0213',
'encodings.euc_jp',
'encodings.euc_kr',
'encodings.gb18030',
'encodings.gb2312',
'encodings.gbk',
'encodings.hex_codec',
'encodings.hp_roman8',
'encodings.hz',
'encodings.iso2022_jp',
'encodings.iso2022_jp_1',
'encodings.iso2022_jp_2',
'encodings.iso2022_jp_2004',
'encodings.iso2022_jp_3',
'encodings.iso2022_jp_ext',
'encodings.iso2022_kr',
'encodings.iso8859_10',
'encodings.iso8859_11',
'encodings.iso8859_13',
'encodings.iso8859_14',
'encodings.iso8859_15',
'encodings.iso8859_16',
'encodings.iso8859_2',
'encodings.iso8859_3',
'encodings.iso8859_4',
'encodings.iso8859_5',
'encodings.iso8859_6',
'encodings.iso8859_7',
'encodings.iso8859_8',
'encodings.iso8859_9',
'encodings.johab',
'encodings.koi8_r',
'encodings.koi8_u',
'encodings.mac_arabic',
'encodings.mac_centeuro',
'encodings.mac_croatian',
'encodings.mac_cyrillic',
'encodings.mac_farsi',
'encodings.mac_greek',
'encodings.mac_iceland',
'encodings.mac_latin2',
'encodings.mac_roman',
'encodings.mac_romanian',
'encodings.mac_turkish',
'encodings.mbcs',
'encodings.palmos',
'encodings.ptcp154',
'encodings.quopri_codec',
'encodings.raw_unicode_escape',
'encodings.rot_13',
'encodings.shift_jis',
'encodings.shift_jis_2004',
'encodings.shift_jisx0213',
'encodings.string_escape',
'encodings.tis_620',
'encodings.undefined',
'encodings.utf_32',
'encodings.utf_32_be',
'encodings.utf_32_le',
'encodings.utf_7',
'encodings.uu_codec',
'encodings.zlib_codec',]

Categories

Resources