Pycharm errors that are not python errors - python

I just installed pyCharm(2016.2) community onto my macBook Pro running El Capitan. I have been using the same version of pyCharm on windows. I copied a simple program to the mac that runs successfully on windows. My mac is catching the following as an error. The error is:
')' expected
Statement expected, found Py:EQ)
The code:
print('See no new', end='')
similarly with
print('See','The','Separator', sep='\t') on the last parameter
where is does not like the end='' part. It wants a closing parenthesis. Windows does not capture this error, and it runs fine in Python 3.5. (My interpreter is set to Python 3.5). It also runs great on Wing IDE and Geany.
I don't understand the differences as I never made changes to Inspections on either machine. And, this is not a python error. I'm ready to immediately abandon PyCharm for another IDE. But I was really happy with it on Windows.
Thanks to anyone answering this question.
Al

Related

Python fails silently

I am trying to get started with Python, so I installed Python 3.8, from python.org (on Windows 10). I remembered to check the "Add to PATH" during the installation and I have confirmed that it has been added to path, as seen in the first image.
However, when I try to use any commands, whether it be python --version or python HelloWorld.py, nothing happens. I have tried both the traditional command line as well as Powershell. I have also tried replacing python with python3, the result is the same. As you can see in the second image, I get no errors, just a blank line. So it's not that it cannot find Python at all, it rather seems that something is wrong with the installation.
Have anyone else encountered this kind of behavior? I have tried re-installing Python as well as removing old installations.
Image 1: Python seems to be correctly added to PATH.
Image 2: Python fails to return any output. But also no error. Same thing happens with python HelloWorld.py.
Update 1 - Here is what I have tried so far:
Changing PATH to refer directly to exe file.
Using both Command Prompt and PowerShell.
Rebooting the PC.
Re-installing Python (including removing old versions).
Both the python and python3 command.
Update 2 - NameError: name 'python' is not defined
Update on the update: This was a wild goose chase. You are not supposed to be able to use that command in the interpreter, as described in this post.
So I tried to use the console from the python.exe file instead, and I got the following answer. However, from what I can find on it, it's normally a problem you encounter on elements of the code (like print()) and not on the python command...?
(image removed)
Update 3 - It works (kinda)
If I use the command py --version or py test.py it works. I have no clue why though...
After extensive research, I still cannot find an answer to my own question. But I have found a work around, which minimizes the consequences:
Instead of using python, simply use py.
This will invoke the Python launcher instead of Python itself (from what I've read). For most people this will be good enough, but it is not the same. So it might cause issues and version mismatch in certain scenarios.
Also, despite of this weird behavior, Python seems to run fine in Visual Studio Code, when using the "Run" button (or the py command in the terminal).

Why does PyCharm return exit code 246?

I am running a script in PyCharm and using the Python 3 installation that is installed with ArcGIS Pro.
Every other time I run the code, it returns "exit code 246", but it is not clear to me what could be causing this.
If I close and reopen the program or restart my computer, I might be able to run the code, but it doesn't work consistently.
The issue doesn't happen consistently so I don't think it's an issue with the code itself.
I discovered the same problem. Problem went away when I did this
try:
import arcpy
except:

Visual Studio code Debugger won’t start on my Python

I have a very simple program written but when I click start on the Visual Studio debugger nothing happens! Sorry total noob here. Working with python 3.6.5 32 bit for Windows. The program runs from the terminal just fine.
def main():
print ("hello world!")
if __name__ == "__main__":
main()
I've just come across the same issue in VS Code (I think) in that I can run a one line python file from the terminal and it will work as expected:
python HelloWorld.py
However when I try to run it in the debugger nothing happens other than the Debug toolbar briefly appearing. I got more suspicious having put a junk console entry in launch.json and it didn't cause any errors.
My problem was that the training instructions I'm following told me to set the following for my workspace settings so it would use the specific python executable in my virtual environment:
{
"python.pythonPath": "env\\Scripts\\python"
}
Once I changed the last part of that path to python.exe, everything worked as expected. Hopefully you can try a similar resolution in Visual Studio.
I had the same issue with all ide programs not just VS.code the problem is when installing python you didn't allow different ide environments to use python and its only executable from windows terminal what you need to do is delete python and VS code completely then again install python 3.x and in the first page of installation check the "Add python to path" box its a must if you want to use something other than windows terminal to code. after reinstalling the python now reset your device and install VS code again and that's it. problem solved

Simple usage of pyDes in IDLE

I wrote the code mentioned in the example section of this page in the shell of IDLE, and it didn't execute and returned "SyntaxError: multiple statements found while compiling a single statement". What is wrong with it?
I have used pyDes some time ago (Python 2.7, Windows XP) and this worked fine for me.
Which Python are you using, and which is your OS?
IMHO, your syntax error is about a few indentation problems == missed tabs\spaces.
Check spaces and tabs in your code, rewrite code manually
I used IDLE 2.7.5+ and the code produced encrypted text and ran just fine. IDLE 3.3.2+ does not work with pyDes for some reason, at least on my OS: Ubuntu Linux.

wx.App (wxPython) crash when calling

Recently I installed wxPython to do some works under Windows. Most of the time I work in Linux so I have a little experience here.
with python.exe interpreter, I just do 2 line of codeimport wxtmp=wx.App(False)
Then the interpreter crashed with Windows error reporting.
I tried both python 2.7.1 and 2.6.6 with wxPython 2.8.11, all come from their main website, still no luck.
Is there something I must do after install Python in Windows ? I can see that python install just fine and can do some basic job, wxPython library can be load, but can't call wx.App
If you are running that in IDLE, then that is your problem. IDLE and wx don't get along very well because you basically end up with two mainloops fighting each other. Try putting it in a file and then run the file from the command line:
c:\python27\python.exe myPyFile.py
That should work just fine. Otherwise, download the correct wxPython for your Python and OS (32/64 bit), uninstall the current one and install the new one. I've been using wxPython on Windows XP, Vista and 7 with no problems like this.
In case like me somebody will stumble into this question like I did. Recently installed wxpython on two machines, windows 7 and XP. Testing the sample code in simple.py (provided with the wxpython docs-demos installer), running from a python console, I had the following problem on both machines: First import ok, but when I did a reload of the module, python crash.
I added this line in the end of the simple.py file: del app
and that fixed the problem on windows 7 and tomorrow I try it on the XP machine.
Same solution fitted for the XP machine. So, reloading an un-edited module with a reference to a wx.App with a closed gui seem not to be feasable. Killing the reference with a del statement was enough to solve the problem.
I searched for a while and found that this is the problem with wxPython and Python >2.5. Tried many fix with manyfest file but no luck, so I think switch to PyQt is the only solution now.

Categories