I am fighting a few hours trying to configure PyCharm for debugging my app. I was looking for solution, but twisted seems to not be so popular and there is weak support. Below I put error log that i got.
/usr/local/bin/python3.4m -u /Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py 57276 57277 /usr/bin/twistd -y /Users/artur/projs/private/elanga-web/start_app.tac
Running /usr/bin/twistd
PyDev console: starting.
Traceback (most recent call last):
File "/usr/bin/twistd", line 7, in <module>
import _preamble
ImportError: No module named '_preamble'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py", line 68, in <module>
globals = run_file(file, None, None)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py", line 28, in run_file
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/usr/bin/twistd", line 9, in <module>
sys.exc_clear()
AttributeError: 'module' object has no attribute 'exc_clear'
Process finished with exit code 1
Couldn't connect to console process.
I will be grateful for an answer why there is no such module like _preamble
On OS X, /usr/bin/twistd is a version of Twisted installed into the system python. This is not python 3.4. The symptom you're seeing is not the missing _preamble module (which is in fact not supposed to be installed, which is why there is an except block around that import catching the exception) but rather that you have pointed python 3.4 at some random python 2 program.
If you want to run python 3.4, you need to create a python 3 environment with Twisted installed. Keep in mind that not all of Twisted is ported, so only a subset of APIs will be available to you. One of the things that is not ported to python 3 yet is the twistd command line, so there's no way to run twistd with python 3 yet.
Related
So I finally got my python program working on my Mac (Catalina 10.15.4), but I am greeted with the following error when it is opened on another Mac (High Sierra 10.13.6.)
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 355, in <module>
_run()
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 340, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/dist/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 9, in <module>
from pysine import sine
File "pysine/__init__.pyc", line 14, in <module>
File "pysine/pysine.pyc", line 1, in <module>
File "pyaudio.pyc", line 116, in <module>
ImportError: dlopen(/Volumes/dist/Riff Gen.app/Contents/Resources/lib/python3.6/lib-dynload/_portaudio.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
in /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib
A simple tkinter test with various sounds and images works fine on the second machine, but not this script. I've tried adding all the packages manually, tried --nostrip, manually including 'libportaudio.2.dylib', and dozens of other ideas from countless outdated forums to no avail.
When the play function of my application is stripped, the app opens and crashes shortly thereafter - giving me the following error:
Traceback (most recent call last):
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 81, in <module>
_run()
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 66, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 2037, in <module>
root.mainloop()
File "tkinter/__init__.pyc", line 1277, in mainloop
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Fatal Python error: PyEval_RestoreThread: NULL tstate
Current thread 0x00007fffa118e380 (most recent call first):
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...none found.
[Process completed]
I have been using Python 3.6 and Py2App v0.13 because it is, unfortunately, the only version that has successfully packaged my program in a standalone package. Any version later than 0.13 gives me the following error even when bundling in alias mode:
Traceback (most recent call last):
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 420, in <module>
_run()
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 414, in _run
exec(compile(source, script, 'exec'), globals(), globals())
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/riffgen_v1.01.py", line 7, in <module>
from tkinter import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ValueError: character U+6573552f is not in range [U+0000; U+10ffff]
I've seen a handful of people with similar errors to the one above, but the few solutions I've seen had no success.
I'm assuming there is a simple solution to both of these errors, but after a long two weeks of tinkering, I'm out of ideas. I just began programming and really want to continue to deploy GUI programs, so I am desperate to get this functional. Any help is greatly appreciated!!
Probably not an answer you were hoping for, but this might give you some ideas where to look:
check if you don't have multiple pythons installed. Make sure you run it with 3.6. (but you probably already did)
Check the modules installed on both PC's help('modules') in a python shell.
Check if the correct version of the modules is installed. Install the exact same versions pip install SomePackage==1.0.4
Symbol not found: ____chkstk_darwin seems to be a very mac related issue. I'd start searching there in combination with the modules you use in your script. This is the only post I found on stackoverflow and it suggests looking at the PATH settings; plaidml-setup uses the wrong lib path and gets OSErrors
What i am trying
I am trying to run behave from a Window machine which don't have behave or any other depended libraries pip installed.
1. Including all modules path to sys.path.
2. Running behave using behave_main method.
Code sample:
import sys
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\behave-1.2.6')
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\parse-1.8.4')
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\selenium-3.13.0')
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\parse_type-0.4.2')
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\traceback2-1.4.0')
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\linecache2-1.0.0')
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\nose-1.3.7')
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\six-1.11.0')
sys.path.append('C:\\MyWorkspace\\synthetics\\features\\modules\\enum-0.4.6')
from behave.__main__ import main as behave_main
behave_main(["C:\\MyWorkspace\\synthetics\\features\\", "-n Login"])
I am able to run behave script this way from my Mac OS, having issue doing the same from Windows machine.
Error:
C:\MyWorkspace\synthetics\features>python run_behave.py
Traceback (most recent call last):
File "run_behave.py", line 16, in <module>
behave_main(["C:\\MyWorkspace\\synthetics\\features\\", "-n NEAT"])
File "C:\MyWorkspace\synthetics\features\modules\behave-1.2.6\behave\__main__.py", line 182, in main
config = Configuration(args)
File "C:\MyWorkspace\synthetics\features\modules\behave-1.2.6\behave\configuration.py", line 647, in __init__
self.reporters.append(SummaryReporter(self))
File "C:\MyWorkspace\synthetics\features\modules\behave-1.2.6\behave\reporter\summary.py", line 49, in __init__
self.feature_summary = {Status.passed.name: 0, Status.failed.name: 0,
AttributeError: 'int' object has no attribute 'name'
Update
I was able to eliminate this issue by running the code with Behave 1.2.5. This issue exists in 1.2.6 version.
On Windows 7 machine, Pycharm (community or professional) and Python 3.4 (tried Anaconda 3 as well) were installed newly. There were not problems running Python scripts interactively in main editor. However, when I tried to select View > Tool Windows > Python Console, it generates the following error messages and more. Basically, I couldn't bring up a console window in Pycharm.
C:\Users\user\Anaconda3\python.exe -u C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevconsole.py 56743 56744
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydev_imports.py", line 21, in <module>
from SimpleXMLRPCServer import SimpleXMLRPCServer
ImportError: No module named 'SimpleXMLRPCServer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevconsole.py", line 20, in <module>
import pydevd_vars
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevd_vars.py", line 9, in <module>
from pydevd_xml import *
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevd_xml.py", line 7, in <module>
from pydev_imports import quote
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydev_imports.py", line 23, in <module>
from xmlrpc.server import SimpleXMLRPCServer
File "C:\Users\user\Anaconda3\lib\xmlrpc\server.py", line 108, in <module>
from http.server import BaseHTTPRequestHandler
File "C:\Users\user\Anaconda3\lib\http\server.py", line 660, in <module>
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
File "C:\Users\user\Anaconda3\lib\http\server.py", line 851, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "C:\Users\user\Anaconda3\lib\mimetypes.py", line 348, in init
db.read_windows_registry()
File "C:\Users\user\Anaconda3\lib\mimetypes.py", line 255, in read_windows_registry
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
TypeError: OpenKey() argument 2 must be str without null characters or None, not str
Process finished with exit code 1
Couldn't connect to console process.
-----------------these messages were showed up in "Python Console"-------------
You need to change your working directory. Go to File->Settings->Build, Execution, Deployment->Console->Python Console and then change or provide a directory where you have read and write access in the Working directory box.
The configuring of pycharm in the presence of various development configurations is a bit of a black art IMHO.
The most effective mechanism I've found for pinning this down is put random strings into the various settings dialogs, Interpreters, consoles, tests , servers and observe the command lines submitted to the interpreter VERY carefully.
Hardly a satisfactory approach but it will sort out what is going where and to a certain degree what effects what.
The other think that helps me are screenshots of the settings and testing dialogs of working installations.
Again, a bit rough and ready but it has got me up and running again after a long period of successful debugging followed by pycharm amnesia.
I had same problem. I reinstalled python and default directories have changed.
Then I just refreshed interpreter here File->Settings->Build, Execution, Deployment->Console->Python Console and here File->Settings->Project: <YOUR_PROJECT>->Project Interpreter.
If you will open new projects interpreter will need choose again (?)
I got it resolved by setting the interpreter in Preferences and project interpreter.
We're about to start using Esky to deploy updates to our application. On Windows 7, Esky appears to be unable to get the escalated privileges it needs to install an update.
I've narrowed it down to this simple script. It asks for escalated permissions, but will either freeze, or crash with the stacktrace below.
Script
import esky
import esky.sudo
class MyProgram(object):
#esky.sudo.allow_from_sudo()
def do_stuff(self):
pass
app = MyProgram()
sapp = esky.sudo.SudoProxy(app)
sapp.start()
sapp.do_stuff()
sapp.drop_root()
Stack Trace
$ python test.py
Traceback (most recent call last):
File "test.py", line 16, in <module>
sapp.start()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 125, in start
raise RuntimeError("sudo helper process terminated unexpectedly")
RuntimeError: sudo helper process terminated unexpectedly
$ python test.py
Traceback (most recent call last):
File "test.py", line 16, in <module>
sapp.start()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 140, in start
self.close()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 156, in close
self.pipe.read()
File "c:\Python27\lib\site-packages\esky\sudo\sudo_base.py", line 123, in read
raise EOFError
EOFError
Does anyone know of a solution, or have any suggestions?
Using:
python 2.7.3
esky 0.9.7
3 years and no answer that is very sad :(
This is a bug in esky.
Esky works fine for me besides the fact that escalating privileges fails.
I'm used to programming in python3... so once I'm done updating Esky to be python 2 and 3 compatible I'm going to tackle this issue.
If anyone wants to solve this problem let's rock and roll! To the github issue tracker!
This is super late, but if anyone in the future has this problem, try running sudo python your_program.py.
After installing and playing around with web.py this morning, plus installing (unnecessarily) pysqlite on a Python26 install (Windows) the Idle interface will no longer start.
Error code I receive:
C:\Python26>python -m idlelib.idle
Traceback (most recent call last):
File "C:\Python26\lib\runpy.py", line 122, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python26\lib\runpy.py", line 34, in _run_code
exec code in run_globals
File "C:\Python26\lib\idlelib\idle.py", line 6, in <module>
import PyShell
File "C:\Python26\lib\idlelib\PyShell.py", line 16, in <module>
from code import InteractiveInterpreter
ImportError: cannot import name InteractiveInterpreter
I've tried a few things, including a reinstall of Python 2.6.6. Nothing has restored Idle's ability to run yet.
Anyone have any ideas on what's wrong/how I can fix it?
Sigh...never mind.
The starter walk-through code for web.py suggested you call your file "code.py". Even though I had this file in my own directory outside of the C:\Python26 folder, it was interfering with the code.py that Python expects (which contains the InteractiveInterpreter code.)
Unless this is a cruel joke by the web.py people, I'd suggest that they change what they suggest that you call the example test code name!