PyCharm connecting to console is stuck - python

I see many have posted the same problem before, but the solutions doesn't help.
I can't run the Console window in PyCharm. I get the error message below shown in the console. And I have set the PATH environment variable using echo %PATH% | clip to copy it. It get stuck at "Connecting to console". What else do I need to do?
\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.
Process finished with exit code 1

Related

i cant run my python code using kivy for making a gui app

**so basically i cant run it it just says what is under here, i used python kivy for gui.it always says this even on different projects.
[CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - ImportError: DLL load failed while importing _window_sdl2: The specified module could not be found.
File "D:\anacondaprogramfiles\lib\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
mod = __import__(name='{2}.{0}.{1}'.format(
File "D:\anacondaprogramfiles\lib\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
from kivy.core.window._window_sdl2 import _WindowSDL2Storage
[CRITICAL] [App ] Unable to get a Window, abort.
.**
i tried alot of stuff i uninstalled python download it from diferent places uninsalled kivy tried other ide PLEASE HELP
I USE WINDOWS 11
PYTHON 3.9
ITS BEEN 2DAYS LIKE THAT
Based on
PS D:\> d:; cd 'd:\\'; & 'D:\anacondaprogramfiles\python.exe' 'c:\Users\khale\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\lib\python\debugpy\launcher' '50433' '--' 'd:\# base Class of your App inherits from t.py'
the file with your code is named # base Class of your App inherits from t.py. That's... very unusual and apparently doesn't work.
Rename your file to something simpler, such as my_app.py, and try again.

how to fix read-only file system error python

I am trying to make a python script that runs the command line for turning a file into a .zip using python3 on my Mac.
However, whenever I run: os.system('zip -er file.zip /Users/mymac/Desktop/file.py') in python3, I get the error:
zip I/O error: Read-only file system
zip error: Could not create output file (file.zip)
I have tried disabling SIP on my Mac, as well as trying to use subprocess but I get the same message every time. I am really unsure why this happens... Is anyone able to help out?
i will suggest 3 steps !
first run :
fsck -n -f
then reboot !
make sure to run the python file as root
import os
try:
os.system('zip mag.zip mag.ppk')
print ('success')
except:
print ('problem')
screnshoot for my test

Windows 10: PIL.Image.open(abc).load(xyz) triggers OSError: Unable to locate Ghostscript on paths

I'm using Python on Windows 10 with PyCharm. My script contains this line:
img = PIL.Image.open(io.BytesIO(ps.encode('utf-8')))
It triggers this error:
Traceback (most recent call last):
File "C:/Users/x/Desktop/ytg2/main.py", line 504, in <module>
generate_terrain(driver)
File "C:/Users/x/Desktop/ytg2/main.py", line 129, in generate_terrain
img = open_eps(ps, dpi=95.5)
File "C:/Users/x/Desktop/ytg2/main.py", line 32, in open_eps
img.load(scale=math.ceil(scale))
File "C:\Users\x\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\EpsImagePlugin.py", line 332, in load
self.im = Ghostscript(self.tile, self.size, self.fp, scale)
File "C:\Users\x\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\EpsImagePlugin.py", line 134, in Ghostscript
raise OSError("Unable to locate Ghostscript on paths")
OSError: Unable to locate Ghostscript on paths
Process finished with exit code 1
So what I understand is that the function load of the object returned by PIL.Image.open uses the package Ghostscript that can't be found with the interpreter.
So here is, in the order, what I've tried to do:
In PyCharm's packages manager, I've installed the following packages: python3-ghostscript and ghostscript.
In Windows 10 Environments Variables, I have added this variable: (name="Ghostscript" ; value="C:\Program Files\gs\gs9.52\bin\gswin64.exe"). Previously, I've of course manually installed Ghostscript (https://www.ghostscript.com/download/gsdnld.html). I 've tried this value too: %ProgramFiles%\gs%\gs9.52%\bin%\gswin64.exe.
However the problem is still here. What could I do?
The PIL.Image.open(io.BytesIO(ps.encode('utf-8'))) uses shutils.which('gswin64c') to find gswin64c (I knew that by clicking on a file link that the Python Interpreter shown in the PyCharm's console, in the error logs - this link is: one of the two last lines beginning with the word File in the error logs I've shown in the OP, if I remember well).
shutils.which('gswin64c') was returning None (indeed, I made myself a print of it) ; so I prompted os.environ["PATH"] and indeed, it was not contained in the printed output. Then to be sure, I typed echo %path% in the Windows 10 CLI, and I made the same constatation.
My conclusion was: I thought I was correctly adding the path of gswin64c in the way I mentionned in the OP of this SOflw Question (via the admin panel) but in fact, I was wrong.
(Maybe this step is optional.) So: first, since it doesn't work, I have deleted the path of gswin64c that I have added via the admin panel (cf.: the OP). This deletion was done via the admin panel too.
Then, to correctly add the path of gswin64c, I've typed, in the Windows CLI: setx path "%path%;c:\Program Files\..........\" (this path must contain gswin64c). Then I've restarted Windows 10 (if I remember well, it was required).
Then I re-printed the result of shutils.which('gswin64c') and gswin64c is found now. Also os.environ["PATH"] and echo %path% correctly output the path of gswin64c.
I hope this answer could help someone. In fact it was not very difficult: one just has to know how to correctly add a path on Windows 10.... Lol.
I was "inspired" by: https://www.windows-commandline.com/set-path-command-line/ ;-) .

import gammu class - getting error no module named

I just want to get status from gammu
import gammu.smsd
smsd = gammu.smsd.SMSD('/etc/gammu-smsdrc')
print smsd.GetStatus()
I saved code to /home/pi/mypython.py
and ran it from terminal
sudo pyhton /home/pi/mypython.py
I'm getting an error
ImportError : No module named gammu.smsd
My target is getting Gammu Status, then if gammu status is stopped I will start it automaticly from other python code.
I was trying:
service gammu-smsd status
Result: No help - just shown usage of gammu-smsd
service --status-all
Result: I'm getting [?] gammu-smsd < unknown is started or stopped
'
Whats wrong with my code? Is there any step I need to do?
The python bindings are separate package, so you need to install it separately even if you already have Gammu installed.

Call Matlab2013 from Python3.x on Windows 7x64

Task: Call a function from Matlab 2013b using Python 3.x on Windows 7 (all x64).
Question: Is there a Python package that allows me to do that?
I already tried:
mlabwrap
python-matlab-bridge
pymatlab
but none of these work with the configuration given above.
Any information about a working configuration using Python 3.x is appreciated.
If you need more detailed information, please let me know.
Update: I am currently trying to get this working using Matlab2011b and Pyhton 2.7 as these seem to be the most used Versions. For now i am stuck at the following:
python-matlab-bridge
I can import the module without problems but as soon as is start a Session a Matlab Command Window pops up and nothing else happens. The Python Window shows:
Starting MATLAB on ZMQ socket tcp://127.0.0.1:55555
Send 'exit' command to kill the server
............................................................Matlab session timed
out after 60 seconds
MATLAB failed to start
Press any key to continue . . .
This happens every single time and no error is given.
mlabwrap
I tried to install mlabwrap using this guide. On typing 'python setup.py install' a Matlab Command Window pops up and again nothing happens. If i close the Command Window the Python output shows:
WINDOWS SPECIFIC ISSUE? Unable to remove c:\users\martin\appdata\local\temp\tmp1
y2kdk; please delete it manually
[Error 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem ande
ren Prozess verwendet wird: 'c:\\users\\martin\\appdata\\local\\temp\\tmp1y2kdk'
INSTALL ABORT: 'matlab -nodesktop -nosplash -wait -r "fid = fopen(\'c:\\users\\m
artin\\appdata\\local\\temp\\tmp1y2kdk\', \'wt\');fprintf(fid, \'%s%c%s%c%s%c\',
version, 10, matlabroot, 10, computer, 10);fclose(fid); quit"' RETURNED ERROR C
ODE -805306369
PLEASE MAKE SURE matlab IS IN YOUR PATH!
My %Path% looks like this (only the important parts ;):
D:\MATLAB\R2011b\bin;C:\Program Files\ZeroMQ 4.0.4\lib;D:\Python27;D:\Python27\scripts;D:\MATLAB\R2011b\runtime\win64;D:\MATLAB\R2011b\extern\lib\win64\microsoft;D:\MATLAB\R2011b\bin\win64
Any help to get any connection between Matlab and Python on Windows is appreciated! I really can´t see why none of this is working...
Update2: I can install mlabwrap now but i can´t start it.
When i try to import mlabwrap a Matlab Command Window opens up and closes after a minute.
The Python output is:
>>> import mlabwrap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python27\lib\site-packages\mlabwrap.py", line 645, in <module>
mlab = MlabWrap()
File "D:\Python27\lib\site-packages\mlabwrap.py", line 405, in __init__
self._session = mlabraw.open(os.getenv("MLABRAW_CMD_STR", ""))
mlabraw.error: Unable to start MATLAB(TM) engine
I double checked that the engdemo from Matlab is working.
I now got it working using python-matlab-bridge.
I converted it by hand to Python3 and the changes have been merged into the official repo so it should work out of the box now.
If you get an error that 'messenger init' could not be found, make sure that Lib\site-packages\pymatbridge\matlab is in your PATH.
If you have any questions or additional information fell free to comment this answer and i will add it to help users get started with python-matlab-bridge.

Categories

Resources