Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
I can't run this old python repository with Python 3.10.10
When i run it displays this error
Traceback (most recent call last):
File "C:\Users\user\OneDrive\Desktop\file\testsimp.py", line 7, in <module>
print (namegen.get_random_name("any"));
File "C:\Users\user\OneDrive\Desktop\file\German_Name_Generator_master\german_name_generator.py", line 68, in get_random_name
name=get_random_from_list(names_w)
File "C:\Users\user\OneDrive\Desktop\file\German_Name_Generator_master\german_name_generator.py", line 50, in get_random_from_list
assert(l!=[] and l is not None)
AssertionError
My python code is (python version 3.10.10):
import string;
import json;
import randompassgen;
import random
import German_Name_Generator_master.german_name_generator as namegen
print (namegen.get_random_name("any"));
Expected: Name Surname
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 months ago.
Improve this question
try:
stemmer = SnowballStemmer("english")
file = open('test_function.py', 'r') # i change .csv to python test file
sys.stdin= file
exec( file )
when I was run python function.py on my function, I got this error i want to execute this function and call the function at test_function.py
Does this work? I believe you can just pass the file name in the exec function. This is my best guess for what to do.
with open("test_function-.py", "w") as file:
# Create simplest code example, remove this when your code is working otherwise it will be overwritten!
file.write('print("Hello, world!")')
exec(open("test_function-.py", "r").read())
Output:
Hello, world!
Edit: I didn't use open before, I hipe you can forgive me.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 months ago.
Improve this question
I compiled a script (running smoothly) that I made in python using Pyinstaller, but the function that converts from word to pdf is stopping the code.
The error:
File "docx2pdf\__init__.py", line 106, in convert
File "docx2pdf\__init__.py", line 29, in windows
File "tqdm\asyncio.py", line 24, in __init__
File "tqdm\std.py", line 1109, in __init__
File "tqdm\std.py", line 1361, in refresh
File "tqdm\std.py", line 1509, in display
File "tqdm\std.py", line 350, in print_status
File "tqdm\std.py", line 343, in fp_write
File "tqdm\utils.py", line 89, in __getattr__
AttributeError: 'NoneType' object has no attribute 'write'
I already tried to reinstall the packages and recompile.
I already put all the functions in a file just in case and compile again, but the error didn't change.
I ran into this same issue yesterday actually and it took me a bit to figure out.
It turns out docx2pdf uses tqdm to display a progress bar in the console. To do this, it writes to stderr to the console.
When I used PyInstaller to create a windowed application without a console, I got this error message as well.
Redirecting stderr for the docx2pdf parts worked for me like the below:
import sys
import docx2pdf
sys.stderr = open("consoleoutput.log", "w")
convert('your file here')
I'm sure there are more elegant, thread-safe solutions on here if you look around though. Hope this helps and Good Luck!
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
When I Code this in python I get an error, but I don't no why, it is an csv file
:
import csv
with open(r'C:\Users\janzi\Documents') as csvdatei:
csv_reader_object = csv.reader(csvdatei, delimiter=',')
print(csv_reader_object)
the error/exception I get:
Traceback (most recent call last):
File "C:/Users/janzi/Desktop/Instagram bot.py", line 3, in <module>
with open(r'C:\Users\janzi\Documents') as csvdatei:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\janzi\\Documents'
You are trying to open your Documents directory, not your csv file.
Specify the entire path to the file, including the filename.
'C:\Users\janzi\Documents' is not a full path, you need to specify the file name and type: 'C:\Users\janzi\Documents\myfile.csv'
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Hi I'm trying to run this code using python I've installed the required modules but It give me this output:
Traceback (most recent call last):
File "sweep.py", line 62, in <module>
Bb_all = zeros((3,0))
File "C:\Python27\lib\site-packages\sympy\matrices\dense.py", line 1260, in ze
ros
return cls.zeros(r, c)
File "C:\Python27\lib\site-packages\sympy\matrices\dense.py", line 521, in zer
os
r = as_int(r)
File "C:\Python27\lib\site-packages\sympy\core\compatibility.py", line 406, in
as_int
raise ValueError('%s is not an integer' % n)
TypeError: not all arguments converted during string formatting
The code's Github: https://github.com/kai5z/Chladni-patterns
I think your problem is on these lines:
Bb_all = zeros((3,0)) # line 62
Bs_all = zeros((2,0))
Sympy documentation says:
sympy.matrices.dense.zeros(r, c=None, cls=None)[source]
Returns a matrix of zeros with r rows and c columns; if c is omitted a square matrix will be returned.
So remove the () and it should work (there are multiple instances where you pass a tuple parameter to zeros -> zeros(3,0) so be sure to fix them all)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
NOTE: the first part of "code" isn't code, it's error message from terminal, SE made me format it that way.
Linux machine using Python 2.7.6
I have download automator which is supposed to take clipboard contents (this works) and download them (this doesn't work). Here is error message:
Traceback (most recent call last):
File "/home/thomasshera/Create polynomial from random sequence.py", line 6, in <module>
urllib.urlretrieve(text_in_clipboard, "/home/thomasshera/Pictures/Star Wars")
File "/usr/lib/python2.7/urllib.py", line 94, in urlretrieve
return _urlopener.retrieve(url, filename, reporthook, data)
File "/usr/lib/python2.7/urllib.py", line 244, in retrieve
tfp = open(filename, 'wb')
IOError: [Errno 21] Is a directory: '/home/thomasshera/Pictures/Star Wars'
Here is code:
import Tkinter
import urllib
root = Tkinter.Tk()
root.withdraw() # Hide the main window (optional)
text_in_clipboard = root.clipboard_get()
urllib.urlretrieve(text_in_clipboard, "/home/thomasshera/Pictures/Star Wars")
This would be straightforward to fix using Python shell except that there is no line 94 of my program- the shell is somehow wrong?
Second parameter of urlretrieve should be a path to a file not to a directory.
urllib.urlretrieve(url[, filename[, reporthook[, data]]])
Copy a network object denoted by a URL to a local file, if necessary.
You may fix it like:
urllib.urlretrieve(text_in_clipboard, "/home/thomasshera/Pictures/Star Wars/download.temp")
Error occurs not in your code, but in the library you use - so why you see line 94 of file /usr/lib/python2.7/urllib.py. But the reason of it is in yours code. urllib.urlretrieve takes filename (not folder name) as its second argument. (In traceback we see that it is passed to function open which expects filename). This will work:
urllib.urlretrieve(text_in_clipboard, "/home/thomasshera/Pictures/Star Wars/data.txt")
First off, the error you see has nothing to do with line 94 of your script, rather it's in urllib.py module.
Secondly, the problem is how you are using urlretrieve method. It takes in an URL and a filename. But you're using path to a directory, rather than a file. And urllib tells you exactly what I just said:
IOError: [Errno 21] Is a directory: '/home/thomasshera/Pictures/Star Wars'
Please, read urllib docs carefully.