I'm having a strange issue I've never experienced in python before. When I try to import the keyboard module: import keyboard, my program sends a segmentation fault. I have ran the program with sudo and without. Ive reinstalled the package, and it still won't work. Any help?
Also, very important to mention but I am on MacOS Big Sur. I believe the lack of permissions are the source of this issue, however I am unsure how to add them.
Code:
import keyboard
keyboard.press_and_release('space')
Error:
usr#MacBook-Air Program % python3 keystrokes.py
zsh: segmentation fault python3 keystrokes.py
With MacOS you have to explicitly allow your terminal program to 'control' your computer. In this case your terminal is controlling the keyboard.
Go to:
System Preferences -> Security & Privacy -> Privacy Tab.
Then: Select the Accessibility and add your terminal program to the list.
In my case it was iTerm, yours may be different.
Note: I am using MacOS 12.5 (Monterey), but here is the link to Apple Support describing the process in more detail (Specifically for Big Sur)
https://support.apple.com/guide/mac-help/allow-accessibility-apps-to-access-your-mac-mh43185/11.0/mac/11.0
Related
I built a python based program. Prior to this project, I have not run a python program from an exe, but I needed to run this project from an exe on a Windows 10 machine. Using pyinstaller I created and tested the final project without issue, but as soon as I set it up on another computer, it returned an "Importing the numpy C-extensions failed" error message. This seemed weird because I did not receive this error on my computer. So I created a clean installation on a VM, and no error. The other system has python installed, but the version is the same as the one I am using on my computer. Regardless of the installed python version, I thought pyinstaller created a stand-alone python environment.
Is there something I should check or compare between the two systems?
Additionally, my system and the VM started the program without a Windows Defender popup, but the problematic system shows a "Windows protected your PC" popup that needs to be bypassed. Is there a Windows defender setting that might be causing this issue?
Thank you to anyone who has information on this issue. I am fairly new to Python and could use any positive advice available.
I have run the program on a clean VM, with no issues. After some research, I tried uninstalling and reinstalling the numpy on the problematic system, but the issue persists. I cannot figure out what is casuing the error on one system but not any others.
I'm running a python script and it used to work (it even does on my other laptop right now) but not on my current computer - I just get the error code:
Process finished with exit code -1073741515 (0xC0000135)
I don't get any other results - not even from "print" commands at the beginning of the file.
I haven't found anything specific to that.
I re-installed python (2.7.9), pygame (1.9.1) and even pycharm (tried 4.5 first, now with 5.0 - same result)
Does anyone know what that error code means? I couldn't find anything about it.
reinstall python – you don't have python33.dll in c:\WINDOWS\system32\
Maybe you have different python versions – look at folders in root of c:
If yes, then point to your version of python.exe in pyCharm > Settings > Project Interpreter
This may be due to another program locking that memory location.
Before you try more drastic measures, know that restarting the computer fixed the problem for me.
The error seems to be related to issues in native code (e.g. C/C++) and might be related to issues in loading some dll file. To know which file, the Windows "Event Viewer" is your friend.
The "Event Viewer" -> "Windows Logs" -> "Application" feed usually shows one or more rows for each crashed application and one of them should list the problematic filename.
Personally I observed similar issue with matplotlib on Python 3.9 (installed using Anaconda on Windows 10). I could see this kind of error when the code was executed using PyCharm. The same code just crashed with no visible errors when starting from Anaconda console.
The Event viewer then showed issue with freetype.dll. In this case, the problem was fixed by downgrading the packege from 2.11.0 to 2.10.4:
conda install freetype=2.10.4
Depending on the exact issue, I could imagine that removing pycache folder might help (like mentioned in other answers). Also, sometimes it might make sense to look at the PATH environment variable to actually understand why certain dll file is loaded from such a location.
I got this error in PyCharm after upgrading pyarrow to the most recent version -- 0.16 --- using pip, running the same code I had ran before this update which used pandas read_parquet specifying the engine="pyarrow" triggering use of this library. After uninstalling and installing the previous version with
pip install pyarrow=="0.15"
the problem resolved.
I encountered the same error when running .py in PyCharm on Windows. Inspired by https://thenewboston.com/forum/topic.php?id=10088, I uninstalled and reinstalled Python. When reinstalling, I checked the ADD PYTHON TO THE PATH Option. After recreating the virtual environment in PyCharm, the error was gone.
Update: On another Windows PC (64-bit), I encountered the same error where reinstalling Python was not enough. I tried two things.
Uninstalling 32-bit Python and installing 64-bit Python. Namely downloading python-3.6.4-amd64.exe instead of python-3.6.4.exe
Recreating the Pycharm project from github.
Between the two actions, the error was gone.
taskkill /F /IM python.exe
Try this if it just happened out of the bloom and it worked normally before that error occurred.
I solved it by disabling "PyQt compatible" checkbox in the Settings under Build, Execution, Deployment --> Python Debugger.
After that, it should debug properly.
Here is caused it and solution:
The computer had two physical processors. The code uses Numba for parallel computations. Upon disabling and re-enabling hyperthreading this issue started. To solve it clear pycache folder and run the program.
I encountered this error in my code as well, in my case the problem was sharing pickle which produced in Unix machine one a Windows one.
**I faced the same situation and the malfunction stems from trying to run both terminal processor and graphical user interfaces. When I clicked the button program stopped running **
Solution: I disabled terminal inputs and work with graphics.
For example:
if you do this
entry1=Entry(root,width=10).pack()
variable= str(input("Whats your name?"))
You will see the error.
if you delete either entry1 or variable, you will not see the problem.
If you're trying create a .svm use dlib probably the problem is in .xml, some image that you use is cause the problem. Try to create a new .xml putting out a image(any image) or remove that your .xml and test, try this even you find out the image problem.
For exemple, the image "treinamento3.jpg" was the problem. I removed this command line:
< image file='delirium\treinamento3.jpg'>
< box top='213' left='86' width='46' height='49'/ >
< box top='531' left='47' width='125' height='123'/ >
< /image >
from my .xml for solve my problem.
I'm running a python script and it used to work (it even does on my other laptop right now) but not on my current computer - I just get the error code:
Process finished with exit code -1073741515 (0xC0000135)
I don't get any other results - not even from "print" commands at the beginning of the file.
I haven't found anything specific to that.
I re-installed python (2.7.9), pygame (1.9.1) and even pycharm (tried 4.5 first, now with 5.0 - same result)
Does anyone know what that error code means? I couldn't find anything about it.
reinstall python – you don't have python33.dll in c:\WINDOWS\system32\
Maybe you have different python versions – look at folders in root of c:
If yes, then point to your version of python.exe in pyCharm > Settings > Project Interpreter
This may be due to another program locking that memory location.
Before you try more drastic measures, know that restarting the computer fixed the problem for me.
The error seems to be related to issues in native code (e.g. C/C++) and might be related to issues in loading some dll file. To know which file, the Windows "Event Viewer" is your friend.
The "Event Viewer" -> "Windows Logs" -> "Application" feed usually shows one or more rows for each crashed application and one of them should list the problematic filename.
Personally I observed similar issue with matplotlib on Python 3.9 (installed using Anaconda on Windows 10). I could see this kind of error when the code was executed using PyCharm. The same code just crashed with no visible errors when starting from Anaconda console.
The Event viewer then showed issue with freetype.dll. In this case, the problem was fixed by downgrading the packege from 2.11.0 to 2.10.4:
conda install freetype=2.10.4
Depending on the exact issue, I could imagine that removing pycache folder might help (like mentioned in other answers). Also, sometimes it might make sense to look at the PATH environment variable to actually understand why certain dll file is loaded from such a location.
I got this error in PyCharm after upgrading pyarrow to the most recent version -- 0.16 --- using pip, running the same code I had ran before this update which used pandas read_parquet specifying the engine="pyarrow" triggering use of this library. After uninstalling and installing the previous version with
pip install pyarrow=="0.15"
the problem resolved.
I encountered the same error when running .py in PyCharm on Windows. Inspired by https://thenewboston.com/forum/topic.php?id=10088, I uninstalled and reinstalled Python. When reinstalling, I checked the ADD PYTHON TO THE PATH Option. After recreating the virtual environment in PyCharm, the error was gone.
Update: On another Windows PC (64-bit), I encountered the same error where reinstalling Python was not enough. I tried two things.
Uninstalling 32-bit Python and installing 64-bit Python. Namely downloading python-3.6.4-amd64.exe instead of python-3.6.4.exe
Recreating the Pycharm project from github.
Between the two actions, the error was gone.
taskkill /F /IM python.exe
Try this if it just happened out of the bloom and it worked normally before that error occurred.
I solved it by disabling "PyQt compatible" checkbox in the Settings under Build, Execution, Deployment --> Python Debugger.
After that, it should debug properly.
Here is caused it and solution:
The computer had two physical processors. The code uses Numba for parallel computations. Upon disabling and re-enabling hyperthreading this issue started. To solve it clear pycache folder and run the program.
I encountered this error in my code as well, in my case the problem was sharing pickle which produced in Unix machine one a Windows one.
**I faced the same situation and the malfunction stems from trying to run both terminal processor and graphical user interfaces. When I clicked the button program stopped running **
Solution: I disabled terminal inputs and work with graphics.
For example:
if you do this
entry1=Entry(root,width=10).pack()
variable= str(input("Whats your name?"))
You will see the error.
if you delete either entry1 or variable, you will not see the problem.
If you're trying create a .svm use dlib probably the problem is in .xml, some image that you use is cause the problem. Try to create a new .xml putting out a image(any image) or remove that your .xml and test, try this even you find out the image problem.
For exemple, the image "treinamento3.jpg" was the problem. I removed this command line:
< image file='delirium\treinamento3.jpg'>
< box top='213' left='86' width='46' height='49'/ >
< box top='531' left='47' width='125' height='123'/ >
< /image >
from my .xml for solve my problem.
I'm learning python + gtk3+ so I was looking for an IDE to help me. Is there any way to get code completion with PyGObject? I've really tried EVERYTHING I can think of.
I have pycharm build 138.2401 where this bug: https://youtrack.jetbrains.com/issue/PY-6932 is supposed to be fixed but I can't get any code suggestions.
This simple code would raise a warning (Gtk is not found):
#!/usr/bin/python3
from gi.repository import Gtk
Also, using fakegir doesn't work either (and it does work with WingIDE). Here is my project start script in case I'm doing something (horribly) wrong:
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])
sys.path.append(self,"/home/obok/.cache/fakegir/")
2020 Fix
will post a fix here that works for me it might help someone
pycharm version: 2020.1 community
os: Manjaro kde
project interpreter: python 3.8 system wide "not a virtual env"
Gtk completion is working only from pycharm terminal, but not from editor area
the proposed solution of putting mouse pointer at Gtk keyword and Then press alt+enter, simply doesn't work because it didn't show option "Generate stubs for binary module"
solution Steps:
Change this line in idea.properties file to
idea.max.content.load.filesize=20000, in may case i used sudo nano /usr/share/pycharm/bin/idea.propertie to edit this file, yours might be in different place, use locate or find cmd to findout.
create a vertual env from pycharm for your current project.
Install Gtk: follow the exact steps in official website here otherwise it will fail, you might need to install package "wheel" into your venv
After finish installing successfully, click on Gtk in from gi.repository import Gtk then press alt+enter, and select "Generate stubs for binary module".
wait.......... until finished.
pycharm will complain there is no type hint for Gtk and offer to
install "PyGobject-stubs" DON'T install it, because it cause
problem.
After all done ... restart Pycharm.
Pycharm will start but will take some more time again for indexing and finally all work.
Using the page you suggested, I tested the solution at the bottom of the page, and guess what, it worked! It took some indexing from Pycharm, but everything now autocompletes!
Just write:
from gi.repository import Gtk
Then press alt+enter, and select "Generate stubs for binary module"
I recently attempted to install python 3.2 along with IDLE 3 on my macbook pro. I successfully installed python 3.2 (as in, I can run it from the terminal), but when I attempted to install IDLE 3.2 I must have done something wrong because now both IDLE 2.7 and IDLE 3.2 crash immediately upon opening with the message "Python quit unexpectedly", no matter whether I open it through the terminal or through finder. Does anyone know how to fix this? I have installed the correct ActiveTCL package (and reinstalled) and still nothing. I have attempted to reinstall python 3.2 and IDLE 3 but I am not sure whether I did it correctly. Through a good amount of googling I found some people say that it was most likely a path issue but all of the solutions I found were using Windows so I am not sure how to apply that to my mac.
Try renaming or removing the directory ~/.idlerc which is about the only thing used by Python that would in common to IDLE for 2.7 and 3.2. If that doesn't help, state exactly which Python 3 you installed, what version of OS X, and show the stack traces from the termination report.
UPDATE: Based on the crash report you've supplied, it appears that Tk is crashing during its initialization of menu items:
...
4 Tcl 0x00000001013dfa61 Tcl_Panic + 162
5 Tk 0x000000010151c523 TkpGetColor + 383
6 Tk 0x0000000101529a25 TkpMenuInit + 156
7 Tk 0x00000001014ac254 TkMenuInit + 88
8 Tk 0x000000010152c687 -[TKApplication(TKMenus) _setupMenus] + 53
...
I have not seen any reports of a similar problems when IDLE is used with A/S Tcl/Tk 8.5 on 10.7.3 and I haven't been able to reproduce it myself on 10.7.3. However, the Cocoa Tcl/Tk 8.5 is not the most robust framework out there and it may be susceptible to problems when using languages or input methods other than US or US Extended. Another possibility (more likely) is if you are using some third-party menu enhancement application or preference panel (to add colors to menus perhaps). If those suggestions don't help you to isolate the problem, I suggest you ask on the Tcl Mac mailing list (tcl-mac#lists.sourceforge.net, archived at http://dir.gmane.org/gmane.comp.lang.tcl.mac).
If you are running Mac OS X Lion, it sounds like you are being bitten by the saved-state crash. You need to delete the saved state to make the crash go away:
http://osxdaily.com/2011/07/17/delete-specific-application-saved-states-from-mac-os-x-10-7-lion-resume/
http://reviews.cnet.com/8301-13727_7-20083707-263/managing-mac-os-x-lions-application-resume-feature/
I had the same issue. I run OSX 10.8.5, Python 3.3.3 and IDLE 3.3.3 and reinstalling Python haven't been a solution.
I solved any problem removing the ~/.idlerc directory. My problem showed for the first time when I tried to change some Preferences (IDLE->Preferences->General->Startup Preferences->At Startup Open Edit Window), so I suppose that's why resetting my Preferences deleting ~/.idlerc folder have been the solution.
I had the same problem where IDLE would crash after I opened it on my MAC
I ended up updating my computer to OS Yosemite.
and the most updated version of python but it still would shut
the reason it started was because I tried to change the preferences for certain keys.
Resetting the preferences fixed it!
I typed mc ~/.idlerc idlerc2
:)
[Solved] I had the same problem here using:
Yosemite 10.10.2
python 3.4.2
The issue was solved downloading and installing the ActiveTcl 8.5.17.0 version from http://www.activestate.com/activetcl/downloads
Best Regards,
Tchê