python-3.4

pyttsx: No module named 'engine'

北战南征 提交于 2019-12-17 10:51:51
问题 I'm trying to install TTS package by using this. Everything was okay until I tried to execute the following command: import pyttsx I got back this error: File "/usr/local/lib/python3.4/dist-packages/pyttsx/__init__.py", line 18, in module <br> from engine import Engine<br> ImportError: No module named 'engine' Any help would be appreciated. Thank you! 回答1: Guys there is an updated package compatible with Python3 : pyttsx3 Works offline with no delay in the sound produced. Installation: pip

JavaPackage object is not callable error: Pyspark

≯℡__Kan透↙ 提交于 2019-12-14 03:55:48
问题 Operations like dataframe.show() , sQLContext.read.json works fine , but most functions gives "JavaPackage object is not callable error" . eg : when i do dataFrame.withColumn(field_name, monotonically_increasing_id()) I get an error File "/tmp/spark-cd423f35-9572-45ee-b159-1b2732afa2a6/userFiles-3a6e1729-95f4-468b-914c-c706369bf2a6/Transformations.py", line 64, in add_id_column self.dataFrame = self.dataFrame.withColumn(field_name, monotonically_increasing_id()) File "/home/himaprasoon/apps

How to convert the data extracted from a file to bytes in python?

允我心安 提交于 2019-12-14 02:28:13
问题 I am a newbie to python scripting. I have to extract data line by line from a text file and then convert each line of data received to bytes or bytearray in my .py file. i am able to extract the data from the file line by line, but not able to convert that to bytes. The text in the file is as follows: 04/nov/14 09:15:30 4.6 2.3 05/nov/14 09:30:45 3.2 06/nov/14 10:00:00 1.2 3.4 5.6 I am not very sure how to use bitArray or bytes/bytearray to the data for conversion. I am sorry I have no code

Replacing lines of output with custom message

和自甴很熟 提交于 2019-12-14 02:23:54
问题 I am trying to build a function that asks the user to enter a taboo word and then a filename. The script should then open the file and print it line by line, but replacing any line that has the taboo word in it with a censorship message such as LINE REDACTED . I'm just stuck on the last part which is adding a censorship message. This is what I have so far: print('Please enter a taboo word and a filename, separated by a comma: ') filename = input('>') while True: try: file = open(filename)

tor name not recognized in stem

十年热恋 提交于 2019-12-13 21:26:43
问题 I am trying to follow the "to russia with love" tutorial (https://stem.torproject.org/tutorials/to_russia_with_love.html) but I am getting this error: [1mStarting Tor: [0m Traceback (most recent call last): File "C:\Users\gatsu\My Documents\LiClipse Workspace\TorCommunicator\tutorialStart.py", line 52, in <module> init_msg_handler = print_bootstrap_lines, File "C:\Python34\lib\site-packages\stem\process.py", line 244, in launch_tor_with_config return launch_tor(tor_cmd, args, torrc_path,

How do I import from a file in the current directory in Python 3?

久未见 提交于 2019-12-13 20:26:03
问题 In python 2 I can create a module like this: parent ->module ->__init__.py (init calls 'from file import ClassName') file.py ->class ClassName(obj) And this works. In python 3 I can do the same thing from the command interpreter and it works (edit: This worked because I was in the same directory running the interpreter). However if I create __ init __.py and do the same thing like this: """__init__.py""" from file import ClassName """file.py""" class ClassName(object): ...etc etc I get

Printing non-ascii characters in Python 3

对着背影说爱祢 提交于 2019-12-13 18:14:33
问题 So I want to print special characters like ® (the Reserved Sign char). Seems easy enough. I found someone else trying to do the same thing but with the copyright symbol and gave it a whirl, but it errored out: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print('\u00a9') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python34\lib

Django 1.8.2 — Tutorial Chapter 3 — Error: NoReverseMatch at /polls/ — Python 3.4.3

蹲街弑〆低调 提交于 2019-12-13 18:13:29
问题 I've been following the official tutorial exactly. It's located here: https://docs.djangoproject.com/en/1.8/intro/tutorial03/ It's been going well, but suddenly I'm getting this error: Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not found. 0 pattern(s) tried: [] It happened as soon as I changed this line: <li><a href="/polls/{{ question.id }}/">{{ question.question_text }}</a></li> to this new version: <li><a href="{% url 'detail' question.id %}">{{ question.question

How to call a Python script with arguments from Java class

北城以北 提交于 2019-12-13 14:33:45
问题 I am using Python 3.4 . I have a Python script myscript.py : import sys def returnvalue(str) : if str == "hi" : return "yes" else : return "no" print("calling python function with parameters:") print(sys.argv[1]) str = sys.argv[1] res = returnvalue(str) target = open("file.txt", 'w') target.write(res) target.close() I need to call this python script from the java class PythonJava.java public class PythonJava { String arg1; public void setArg1(String arg1) { this.arg1 = arg1; } public void

How is __mro__ different from other double underscore names?

♀尐吖头ヾ 提交于 2019-12-13 13:26:03
问题 I stumbled upon this behavior for double underscore name that I don't understand: class A: pass class B: pass class C(A,B): __id__ = 'c' c = C() print(C.__mro__) # print the method resolution order of class C #print(c.__mro__) # AttributeError: 'C' object has no attribute '__mro__' print(C.__id__) # print 'c' print(c.__id__) # print 'c' I know about the name mangling for __name , which doesn't apply for __name__ (more for overloading operator methods). __id__ behaves just like a regular class