Python 2.7 with Spyder 3.0 - python-2.7

I installed Spyder 3.0 and also python 2.7. I want to run python 2.7 codes with spyder 3.0
I tried to change python interpreter in spyder preferences. "Preferences->Python Interpreter-> Use the following Python interpreter". I chose Python 2.7 but it did not work. I also searched Python 2.7 executable file but I could not find it in the location usr/bin (ubuntu 18.04).
How can deal with this problem?

Spyder installation is specific to one version of Python.
1) install python 2.7
2) run python2.7 -m pip install spyder in cmd
3) you should find spyder in C:\Users\YOUR_NAME\AppData\Local\Programs\Python\Python27\Scripts\spyder.exe (for Windows at
least)
4) You can make a shortcut of it
you should see the python version in the Spyder window title

Related

Can't change from Python 2.7 on VS Code on Big Sur

I've installed Python 3.9 on my Mac, and used Python: Select Interpreter in VS Code to change to it. VS Code is telling me its using Python 3.9 in the status bar, but when I type "python -V" in the terminal it tells me its using Python 2.7. See attached screenshot.
screenshot
Python 2.7 comes pre-installed in MacOS. The command python refers to it.
If you want to use python 3.x instead, you have to use python3 (as in python3 --version)
If you would like to invoke python3 even when you type python, you can add an alias to your bashrc or your zshrc (depending on which you use) such as
alias python="python3"

SciPy in Python 2.7 and Python 3

I would like to use a module (that requires scipy) in Python 2.7, but for some reason the Python interpreter tells me that I am missing a scipy.special. I do not know why is this, because such an error did not occur when running the Python 3 interpretor.
I have attempted to install scipy through Anaconda and pip, but neither of those options seemed to help.

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.

No module named numpy error in python 2.7.8

I'm trying to get Numpy working in Python 2.7.8, on a Ubuntu 12.0.4 operating system. I installed Python 2.7.8 as my default python, then installed the SciPy stack according to the site instructions. I double-checked that numpy installed in the /usr/lib/Python2.7 directory. When I run python the version is 2.7.8, but of course it can't find Numpy. Is there any way to fix this? Or should I just throw this computer out the window?
Edit: Apparently I have both 2.7.8 and 2.7.3 installed, both to Python2.7 directory. I have no idea how to get rid of either one...

import pygtk works but not import gtk

I am configuring pygtk in my centos 5.4 machine. But I am facing few issues.
I want pygtk to be configured to Python 2.7(The default python version is Python 2.4 in centos 5)
So I installed Python 2.7 with different --prefix to my local space and then installed pygobject2.28 and then pygtk2.24 with the --prefix="where python 2.7 installed".
But when I run python2.7 interpreter I am able to import pygtk but, when I try to import gtk it says "no module named gtk."
I have configured PYTHONPATH and PYTHON environment variables to python2.7/lib/site-packages and python2.7 respectively.
My questions:
if pygtk is a wrapper for gtk then why am not able to import gtk, when I am able to import pygtk.
Where does python(or pygtk) pick the gtk from?
And how can I solve the above problem!?
I tried google and other stack overflow questions. But none of them answered the above quesions.
I wasn't checking the ./configure output properly. The problem was, I was trying to install gtk and pygtk without installing cairo and pango. So pygtk skipped building gtk packages because it did not find any cairo package. This was mentioned in the ./ configure script but I had not checked that.
Summarizing:
To configure pygtk to python need to folow these steps
install sqlite-devel #If sqlite needed
install python(2.7)
install gtk(2.24.0) -> requires glib(2.27.3), atk(1.29.2), cairo(1.8.10), pango(1.22.4), gdk-pixbuf(2.21.3)
install pygtk(2.24.0) -> requires pygobject-2.28.3, pycairo(1.8.10)
All the above packages must be compiled to the same prefix, and need to set the PYTHON and PATHONPATH environment variables. The versions of packages also play major role. Added version in parenthesis that worked for me.
There are many dependencies while installing some of the packages so I had to install following packages using yum: libxext, librender, gettext, zlib, libgtk2-devel