User Input with Python on Anaconda? - python-2.7

I installed Anaconda (python version 2.7) with Spyder on my Windows 8.1 machine. I'm taking some tutorials and would like to write a short program that I can run from Spyder - it should take user input and print it. Literally something like:
var = raw_input()
print(var)
But I can't do this from a Spyder, and Python doesn't seem to have much for this in IDEs.
After some searching I found this: http://bugs.python.org/issue5680
Will this let me run the script out of Spyder? If so, what is the correct way to install it?
Thanks!

Got it. Python 3.4 uses input(). raw_input() is from 2.7.

I guess Spyder doesn't support raw_input. You may need to run your script using just python.

Related

Sublime text 2 can not find any python module

I am leaning programming now and get stuck in the very beginning.
I have sublime text 2 installed on my Mac, and I type some python code in and it runs. However, when I start to import module like pandas/matplotlib, it can not find those modules. Certainly I have used pip to install them.
So what is the solution please?
Does Your code work with those modules when You use a different editor?
If it doesn't, Check if the modules You need are indeed installed. You can do this either by using the python prompt:
python
>>> help("modules")
>>> exit()
or using pip:
pip freeze
(sorry for posting this as an answer, but I'm currently not able to post comments)

spyder, numpy, anaconda : cannot import name multiarray

I am on Windows 10, 64bits, use Anaconda 4 and I created an environment with python 2.7 (C:/Anaconda3/envs/python2/python.exe)
In this environment, I successfully installed numpy and when I type "python", enter, "import numpy", enter, it works perfectly in the anaconda prompt window.
In spyder however, when I open a python console and type "import numpy", I get "cannot import name multiarray". I have obviously changed the path of the python interpreter used by spyder to match the python.exe of the environment I created (C:/Anaconda3/envs/python2/python.exe). I also updated the PYTHONSTARTUP to C:/Anaconda3/envs/python2/Lib/site-packages/spyderlib/scientific_startup.py
It's supposed to be the exact same python program running but it's two different behavior. How is it possible and how to fix it ?
PS: I already tried the various solutions to this error like uninstalling numpy and reinstalling it. It shouldn't be a problem with numpy since it works just fine in the python console of the anaconda prompt window.
I solved the problem by executing the spyder version of the python2 environment.
It is located in Anaconda3\envs\python2\Scripts\spyder.exe
I have encountered same issue. I have followed every possible solution, which is stated on stack-overflow. But no luck. The cause of error might be the python console. I have installed a 3.5 Anaconda, and the default console is the python 2.7, which I have installed primarily with pydev. I did this and now it is working absolutely fine. Go to tools>preferences and click on reset to defaults. It might solve the issue. Or another solution is to uninstall the current Anaconda i.e. y.x and installing the correct one according to the default. In my case 2.7 Anaconda instead of 3.5

How to select what version of Python Spyder will open on Ubuntu 16.04?

I have been struggling with multiple versions of Python on Ubuntu 16.04. I have versions 2.7 and 3.5. I have followed the steps from the Anaconda site as to how to switch from one environment to another with "source activate snakes". That works well when just looking at the default when calling python from the terminal, but when I attempt to open spyder IDE, no matter what other version is the default, it just opens on python 2.7.
Any ideas how this can be switched in a non permanent way, since I need both versions of Python?
Thanks in advance,
Do you have spyder3? I have spyder and spyder3. Depending on which of those spyders I'm opening the default python would be 2.7 for spyder and 3.5 for spyder3. I open spyders from terminal in ubuntu. That might not be the most reasonable solution, but it works.

Python version settings

I work on Ubuntu with Wingware Python IDE. The version, which we use by our projects is 2.7.X
This morning I updated the IDE, and it became a version >3.x.x
Now I want to install the old version 2.7.3, after I read TFM and try to define PYTHONPATH, I check my Python version on Ubuntu with the command:
python --version
and got the answer 2.7.3. Now I can not understand, why I have version 3.x.x in Wingware and how exactly (the import file is not clear) I can change my version after setting Python manually described here
Actually: It depends on wingware, because I can execute Python 2.7.3 in IPython and in console.
EDIT: I solved this problem myself. Here's my solution:
Following the manual:
Use Python - Executable
Use Interpreter to find right path (in my way it was /usr/bin/python3.2)
Go in /usr/bin/
Select right Python version. This path has ALL Python versions, you should just select the right one
I solve this problem someself. I post now my solution for other people.
After [manual][2] using:
Use Python - Executable
Use Interpreter to find right path (in my way it was /usr/bin/python3.2)
Go in /usr/bin/
Select right python version. This path has ALL Python version, you should just select the right one

How can I remove a version of Python in Ubuntu 12.04?

I have just installed Ubuntu 12.04 which comes with Python 2.7. I have installed Python 3.3, so now I have both versions. For example, if I type python in the terminal I get version 2.7 and if I type python3.3 I get that version.
I don't see why I would need 2 versions (?) so how do I uninstall Python 2.7? And if I do so, will the "python" command then point to Python 3.3?
VERY IMPORTANT EDIT
Removing an older version of python may be very dangerous and can cause trouble in your whole system! For your case instead of removing the older python you can simply use an alias in your terminal, so that when you type python it opens python3.3;
Here is the procedure, add this line:
alias python=python3
Into~/.bash_aliases or: ~/.bashrc
Btw I guess If you ask this question in AskUbuntu you may have a quicker/better response!
You should never remove the builtin Python in your Ubuntu distribution. Bad things will happen if you do.
It is highly recommended to use virtualenv to install other Python environments.
Here's a good Stackoverflow question that demonstrates how:
Is it possible to install another version of Python to Virtualenv?