So I'm trying to set up Eclipse for Python use.
I downloaded the 64 bit Eclipse, 64-bit Java SDK environment, and the PyDev extension for Eclipse.
I've been trying to follow this particular tutorial: https://www.youtube.com/watch?v=CryTwaJGpPM
I am using Python's 2.7 grammar yet my print statement (print p) is saying invalid syntax and works if I use Python 3.0 grammar [print (p)]
The following screenshots outlining the run config, interpreter, grammar version I'm using, and output.
http://imgur.com/a/jvnTa
Any idea on why it's enforcing the 3.0 grammar?
I would like to use 2.7 or 2.6.
Thanks for your help.
Look carefully at your screenshot of the run configuration. All of your paths are set to C:\Python34. Change them to your Python 2 directory, so you'll be using the correct (Python 2) libraries.
Also, look at your last screenshot: you may have Python 2 selected as your grammar, but you've configured it to use your Python 3.4 interpreter when it actually executes. Change your interpreter setting to wherever your Python 2 interpreter is and it will execute your scripts with that interpreter instead.
Related
All support seems to be for Python version 3. Surely there must be a way to get correct syntax highlighting / basic linting for Python 2.7 in VS Code?
I am doing a piece of uni coursework that requires us to use version Python 2.7 and want to be able to get this set up and working within VS Code for easy development and debugging.
Any plugins or modifications to the settings of IntelliSense I can use?
Cheers,
For auto-completion, you can turn off auto-completions, or select Pylance as your language server as it may provide a good experience if the code is compatible enough with Python 3. We will continue to support selecting Python 2.7 as an interpreter in your workspace. For tools that keep support for Python 2.7 in their actively maintained version, we will continue to support using them with Python 2.7.
For more information.
PyCharm 2017.2 highlights my f-strings with the message Python version 3.5 does not support a 'F' prefix.
But...
In File | Settings | Editor | Inspections, Code compatibility inspection is unchecked, both for Default (stored in IDE) and for Project Default (stored in project). (I have seen other questions where the answer was about this point. Not applicable here.)
Even if I turn Code compatibility inspection on and check only Python 3.6, I still get the message about Python 3.5.
File | Invalidate Caches / Restart fixes it briefly, until the Indexing message goes away, then it comes back.
I don't have Python 3.5 installed (only 2.7, 3.6 and 3.7). Python 3.7 is set as the project interpreter.
This behaviour is new, since I started using Python 3.7 for real. If I change the interpreter back to Python 3.6 it goes away. I don't regard that as a useful workaround.
Either this is a bug I should report, or I am missing something that should be obvious. Anyone care to tell me which it is?
I think PyCharm 2017.2 is too old and you should use PyCharm 2018.2. That old version was published before Python 3.7, so you may encounter troubles…
I am new to python. I am writing programs in NetBeans.
NetBeans 8.1
Python Plugin for NetBeans
Python 3.5.1
Plugin is set up for 3.5.1, instead of the default 2.7
NetBeans complains when I write the statement
print ("_ ", end='')
The error is
no viable alternative at input '='
It appears that NetBeans is checking for 2.7 syntax, instead of 3.5. I am able to run the code, so NetBeans is using 3.5 to execute.
How do I configure NetBeans so it uses the correct syntax checking?
After the recommendation of #alecxe, I reported a bug to NetBeans.
NetBeans does not support python 3.x. The plugin runs the correct version, but the IDE syntax checking is linked to 2.x.
Thank you for your report. Note that we do not officially support
Python 3.x yet. However, It is a high-importance task on our nbPython
Jira board... Marking this bug as Duplicate. Suggest you follow
Bug#229940 for notification.
PS. PyCharm is great.
The problem is reproducible on my end too. Even if the default Python Environment is set to Python3.5 and the Project Interpreter is also set to Python3.5, it still uses Python2 specific syntax checks. For example, it does not highlight the print if it is used as a statement and not function:
I don't think this particular behavior is configurable and this is a bug (I suspect the bundled Jython is used for the "live" syntax checking). You should definitely file an issue here.
External tools like PyLint might help, but it is not yet integrated.
And, just saying, PyCharm has a completely free community edition.
I'm a newbie programmer just installing Python 3.2, but I know I also have an older version of Python on my machine. in fact, I think Macbook comes with it installed. Do I have to worry about having different versions on my computer when I try to start learning Python?
For the most part, you don't have to worry about conflicts with system Python. In fact it is recommended to install a different Python version instead of working with system Python. Also consider using virtualenv and virtualenvwrapper to maintain any dependencies for each project easily without conflicts.
It really depends what OS you're talking about. I'm assuming you're talking about a Mac, since you mentioned Macbook.
Macs come with 2.5 and 2.6 installed as far as I'm aware. At least mine has both those versions, and I've only installed 2.7 manually.
You can check which version of python is the current 'system' python by doing the following in terminal:
// check the version of system python
python --version
// tells you where the system version of python is on your PATH
which python
On *nix type Operating Systems, like your Mac, applications aren't really 'installed', like they are in Windows (eliding details). Instead, application files are placed in various different parts of the file system. Python, for example, is placed into the following directory (by default) when installing 2.7:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Since this directory isn't on the system PATH, this version of python won't be used when simply calling python from the command line. The system will search all the folders in the PATH environment variable for an executable file called python. It will usually find it in /usr/bin/ or something similar.
To make a new version of Python the 'system' python, you have a couple of options:
Modify your .bash_profile, and prepend the path to your new python to the PATH environment variable.
symlink the new version of python to a directory already on your PATH like /usr/bin/
Be aware that Mac python installers can modify your .bash_profile (in your home directory), to force the new version to be the default system version. This is what my bash_profile shows:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
You can happily run multiple versions of python on the same system. A particular version is usually the default though, and that's whatever executable python file is found on the PATH first.
If you want to use a different version at any particular point in time, you can:
/path/to/python/2.4/python some_script.py
/path/to/python/2.7/python some_script.py
/path/to/python/3.2/python some_script.py
That will execute the script some_script.py under 3 different versions of python. Of course, you need to make sure that the /path/to/python is correct.
So yes, you need to be mindful about what version of python you are going to be using, hopefully this will guide you into understanding how applications are installed and which version of an application is launched by default when you don't provide a path.
Yes, 3.x Python syntax is not backward-compatible with 2.x. So if you learn Python 3.x you might not be able to port your knowledge to Python 2.x.
Moreover you should choose if you want to learn 3.x or 2.x. 2.x is far more widespread than 3.x, but 3.x is where Python is heading. No more innovation will happen in 2.x, and in mid-term most frameworks will be ported to 3.x (right now there are some notable exceptions)
Hope that helps!
In general, you should be fine. Since the Mac is BSD-based, it should maintain the "python" command as pointing to the version that your system requires, which is usually an older version like 2.5. You may have to use a command like python3 to run your Python 3 programs, but other than that it should be transparent to you.
As you learn and become more advanced, you can begin using the virtualenv system to maintain separate Python installations for multiple projects.
Python version with different major or minor version numbers can be installed in parallel. For example, you can have 2.4, 2.5, 2.6, 2.7 and 3.1 on the same machine. However, you can't have versions with the same major and minor number installed at the same time (at least, not without tricks), so you can't have 2.5.2 and 2.5.4 at the same time.
Note that you will have to install any third-party libraries once for every Python version.
It is very well possible to have multiple versions of python on your machine. Just make sure, that if you call python in your console it uses the python you want it to use. Same goes for your IDE.
Regarding the version: It is always nice to have the latest version on board (in python however there are compatibility issues to take into account) , since there might be features you want to use, that are only available with a certain version and upwards. Since this is sometimes tricky to find out, especially if you are new to the field, going with the latest version might be how you should proceed.
Be careful before installing new version of python.
Python has no backward compatibility.
Scripts written for python 2.7.* won't work on python 3
For example,
print "Hello" will work on python 2.7 but not on version3
I'm trying to find a decent IDE that supports Python 3.x, and offers code completion/in-built Pydocs viewer, Mercurial integration, and SSH/SFTP support.
Anyhow, I'm trying Pydev, and I open up a .py file, it's in the Pydev perspective and the Run As doesn't offer any options. It does when you start a Pydev project, but I don't want to start a project just to edit one single Python script, lol, I want to just open a .py file and have It Just Work...
Plan 2, I try Komodo 6 Alpha 2. I actually quite like Komodo, and it's nice and snappy, offers in-built Mercurial support, as well as in-built SSH support (although it lacks SSH HTTP Proxy support, which is slightly annoying).
However, for some reason, this refuses to pick up Python 3. In Edit-Preferences-Languages, there's two option, one for Python and Python3, but the Python3 one refuses to work, with either the official Python.org binaries, or ActiveState's own ActivePython 3. Of course, I can set the "Python" interpreter to the 3.1 binary, but that's an ugly hack and breaks Python 2.x support.
So, does anybody who uses an IDE for Python have any suggestions on either of these accounts, or can you recommend an alternate IDE for Python 3.0 development?
Cheers,
Victor
Try PyCharm from JetBrains.
You did not mention these so I'm not sure if you've tried them but there are:
- Aptana (aptana.com)
- The Eric Python IDE (http://eric-ide.python-projects.org/)
- WingWare Python IDE (wingware.com)
I haven't used any of them so I don't know if they will match your needs, but I'd expected them to be pretty close as they are all mature.
As for PyCharm, I've been using it for a while and it's fine, actully I like it very much.
However I'm a Python noob and probably do not use many advanced features so YMMV.