I work on two computers, I have Sublime Text 3 and Python 2.7 on both of them.
Recently, without changing any configuration (except maybe installing some packages like ANACONDA for ST3), when I build my python code on Sublime Text 3: e.g.,
print 'Hello world'
Console output is just showing:
[Finished in 0.1s]
And nothing more, (I want to see the printed text), this is quite irritating because for the life of me I can't figure out how to solve this.
A related and perhaps identical problem is experienced by #Jens_Leersen.
I've tried the answer contained in #radioxoma 's answer but to no avail.
Related example
I got that thing as well. You can change it by Tools/Build with and choose "Python" instead of "Python- Syntax Check". It turns out that I clicked "Syntax Check" the first time I try to compile. My dumb mistake costs me a few minutes of panic.
This got fixed by uninstalling python 2.7, and installing Anaconda with python 3.5, then installing anaconda through Package Control.
Use Ctrl+shift+b this will show a box asking you if you want to use Python or Python Syntax Check. Select Python and once you are done you will be able to use Ctrl+b to build you code and see the output at the bottom. this answer is just about the same as #1757 answers right below i am just using shortcuts to get to the same functionality
Thank you #1757
Its simple, press ctrl + shift + b and click on python (not python - syntax check).
Build and Voila!
Related
I've been using both VS Code and Sublime for a while now. I mostly do my python coding in Sublime and I have recently decided to try out VS Code. One issue though.
The syntax highlighting for python is not functioning in the manner I would expect. Here is a .py file opened in both VS Code and Sublime for comparison:
Sublime Text:
VS Code:
When comparing the VS Code syntax highlighting to that of Sublime, it appears to only function half correctly.
Tons of stuff that I would expect to receive some form of colored formatting such as function calls, function parameters etc all just appear as white text.
After looking at loads of VS Code python tutorials online, it would definitely seem something is wrong with my setup as everyone else seems to receive function calls/function paramters/etc syntax highlighting.
Troubleshooting progress so far:
I have the VS Code python extension installed.
I've tried uninstalling and reinstalling VS Code.
I've tried uninstalling and reinstalling Python extension.
I've tried installing the magicPython
extension.
Ensuring I have both python2 and python3 installed on my machine
Color theme is currently Dark+, however this behavior occurs with all
color themes.
Made sure the file ends in .py
I'm running on a Mac, if that's relevant.
Any help would be greatly appreciated. Thank you!
i think you just need to change your theme
check this one out https://github.com/sobolevn/dotfiles
I have been running Visual Studio code on the Mac for about 2 years now and I'm running into issues that I haven't seen before. I have not personally run any updates for Code for quite a while. lets say late November.
1) A message at the lower right of my Work space that says
The macOS system install of Python is not recommended,
some functionality in the extension will be limited.
Install another version of Python for the best
experience.
Unfortunately I can't update to Python 3.x and it shouldn't be up to Code to force me to update. Is there a way to turn this message off?
2) Related to above is that some classes or language keywords (JSONUtils, #unittest, requests, def) are no longer being recognized. Some constants that I have created and a variable defined to store a class.
sc = SomeClass()
This will be recognized at definition but later during usage it will not be recognized.
sc.SomeMethod( 1, 2, 3 )
sc won't be recognized. None of this is making sense to me as it is not a pure pattern. Everything is probably the same issue. Need to point Code to python 2.7.
This is a bug in VS Code. A new future version will have an ignore button.
VS Code Issue 4448
I still can't comment, so here it is an an answer instead...
This looks like a duplicate of How can I change python version in Visual Studio Code?
The short version that worked for me:
CTRL+SHIFT+P to open command palette
Choose "Python: Select Interpreter"
Point VS Code to the Python interpreter you wish to use.
Edited to include a specific example
I am learning to use python and work in a windows 10 environment (although on 3 separate computers). I have gotten past the "add python to %PATH% issue" but continue to see odd outcomes when I call simple scripts from powershell compared to running them from the python terminal. For example, I often see that lines of code are duplicated, even simple print statements. A second repeating issue is that some (but not all) modules work fine in the python terminal but can't be found when running a script from powershell, despite using pip install within powershell to install it in the first place.
Rather then seeking help on a specific issue, I'm hoping for some guidance into how powershell and python interact that might help me understand or identify some commonalities in these issues I keep experiencing that are common from within powershell. If thats as simple as redirecting me towards another source even that'd be apprecaited. But my search results always turn up the common issue of powershell not knowing what python is, and needing to add python to the PATH. But as indicated, I have already gotten past this and can get %50 of my python to work from powershell. There must be something else perhaps obvious to others that I'm missing that can help me understand why some things aren't working while others are.
Thanks for taking the time to consider my problem and any advice is greatly apprecaited.
Here is an example from some code I am trying to get working, but in troubleshooting I have taken out a lot of code and am now only running what is shown that defines a dataframe and a print statement. Everything works line by line in python, but when I call the script from powershell, the print statement executes twice.
#!/usr/bin/python3
import pandas as pd
joedata = {'fpr': [0.2,0.4,0.8], 'tpr':[0.9,0.5,0.1]}
joeframe = pd.DataFrame(data=joedata)
print(joeframe)
Concerning modules, you probably have multiple versions of Python installed on your system. Calling pip in the Powershell doesn't mean that it will install for the Python installation which is called by default when you execute Python in the Powershell. So you should try to figure out on which version pip is installing packages and which version is actually used when executing a script.
EDIT: I tested the example that you gave in Powershell and I don't have the problem, it's working fine.
Moreover, for me, without doing any special configuration, in Powershell the commands pip and python refer to the same version of Python. If by default everything is ok, you should consider uninstalling Python and just running the installer again and let it manage the PATH, etc.
I am trying to set up Python on Windows 7. I haven't used this language before so it seems strange to me.
I've downloaded lastest Python release 3.2.2 from official site and upadate path variable.
However I still can't even run simplest program ever like this :
print 'Hello, world!'
It says that there is a syntax error and the last character ' is highlighted with red.
I don't know if my path variable has been set properly. Here is where I installed Python :
C:\Software\Python32
So I added such a variable : var name = PYTHONPATH , var value = C:\Software\Python32\Lib
Is there something with auto-completion and with errors/warnings details ( which line, hint what can be wrong ), for example like Eclipse or NetBeans OR should I use this installed Python IDLE GUI for delevoping or stuff like NotePad++ ?
Actually what is this Python shell for ? - I know that I can type in some arithmetic operations here and I will get results, but is it used for something more advanced ? ( Is it used when I am writting something bigger ? )
Could someone describe simple way to write and execute a program ( or script I a total beginner so I don't really know what it is going on here ) ?
In Python 3.2 you have to use print in the below manner. The parentheses are mandatory. (print became a function in Python 3)
print('Hello World')
As Venk stated, the print statement in Python 2.x has been replaced with print() in 3.x, so your statement should read
print('Hello World')
Since you're new, here some things you should know about Python versions:
Python currently comes in two flavors: Python 2.x and Python 3.x.
Python 2.x has been in development since the late '90s, so most existing codebases, frameworks, and libraries are written in this flavor of Python. Each successive version is backwards compatible, so, for example, all code written in Python 2.4 can be run with Python 2.4+. Its current revision is 2.7.2, which was released last year.
Python 3.x is considered the "future" of Python, and purposefully breaks a lot of the conventions, such as the print statement, in favor of a clearer, more explicit language. Most libraries are working to port over to Python 3.x, but since there are extensive changes in the structure of the language, most library maintainers have not yet been able to release a Python 3.x compatible version with the full features of the Python 2.x version of the library.
If you're developing now, you should learn Python 2.x; otherwise, it's recommended you learn Python 3.x.
To answer your other questions:
Python's native IDLE is an excellent IDE, but if you're looking for something more advanced, you may want to try out Eclipse's PyDev extension or PyCharm. I personally prefer PyCharm, since it doesn't keep giving me errors when I'm importing/using nonstandard Python libraries/frameworks.
In addition, Python's shell is used to interpret Python scripts (in the background) and for interactive interpreting (i.e., quick and dirty testing), and can execute code you type into it. The latter, however, is not recommended, as a single syntax error in multiple lines of code can force you to retype all the lines to fix a single bug.
Furthermore, all Python scripts end in .py, so if you can see the file extensions, you can convert a text file into a Python script, and run from shell by typing python path/to/file.py. Note, however, that you still have to write a valid Python script, or it will not run.
I suggest A Byte of Python. It'll take you through install, REPL, syntax, and the std library.
The python shell is for entering code interactively.
Try the following: http://docs.python.org/tutorial/
I've been using Python on Windows 7 for 3 years now, and I strongly recommend Notepad++ as your editor/interpreter. It is ideal for people who want to play around with the language and are learning. Notepad++ can be customized for almost any language and is free for Windows. Follow this link
and take a look at how to conveniently use Notepad++ to execute Python scripts.
I am trying to get some kicking in python and decided to run python on my ubuntu natty installation, still I am having a weird problem...
It seems that inside the interpreter my keyboard keys are completely swapped by US keyboard ones, like, when I try to type a ' it gives me a ?.
The thing is, how do I change this setting on python interpreter?
The issue isn't with python. this might help: http://pubs.opengroup.org/onlinepubs/000095399/utilities/stty.html