I am trying to set up iPython to use 2.6 version instead of 2.7. Is there a way to do it?
More information.
I am trying to set up a iPython notebook to develop Spark application, however, the python version across the whole cluster is 2.6 where only the name node has the latest Anaconda python version installed 2.7. In that case, when I started a python notebook, it will use 2.7 as the interpreter and I am running into errors when I tried to distribute the work.
Instead of upgrading the wholecluster to use 2.7, I prefer downgrade the iPython version on the name node to be 2.6, is there a way to do it?
Update:
Thanks for the suggestion from Jivan, it is actually fairly easy to use python virtualenv to install the older version of iPython inside the virtual environment, whenever you want to use it, you can have a bash script looks like this and there will be a proper iPython notebook environment that has the python version consistent across the cluster.
#!/bin/bash
which python
source /root/user/python-ev/bin/activate
which python
ipython notebook --profile=pyspark
iPython 1.0 is the last main version of iPython to support Python < 2.7 interpreter.
So you need to install iPython 1.2.1 at most, if that's not done already.
Now to associate it to Python2.6:
$ sudo python2.6 setup.py install
More information on this link. The author skipped the part about which version of iPython to use because at this time all versions of iPython supported Python < 2.7.
It could work, but it's not certain because it depends on your existing config, etc.
If it doesn't, a different way (a bit hacky however) could be found here.
Related
In case it is relevant, I am using Ubuntu 16.04 LTS. I went to install some software (Jupyter Notebook) which uses Python, and the recommendation was to either use python3 install if I have Python 3, or python install if I am still using 2.7.
My Ubuntu installation came with both. python --version returns 2.7.12 and python3 --version returns 3.5.2. However I also know that there is currently a Python 3.6 out there, which I installed... but it appears to use its own special reference python3.6 --version which returns 3.6.4, whereas I had expected it to upgrade/replace python3 so doing python3 --version would return 3.6.4, but nope.
I'm not sure what the correct approach is here because apparently I shouldn't be messing with the Python versions that come installed since the OS may rely on them. At the same time it seems strange to install software that calls for Python3 even though it's going to be using 3.5 rather than 3.6.
Am I overthinking this? Is it expected behavior to use python3.6 specifically for 3.6-related features? Or do most people re-alias python3 to redirect to python3.6 instead? What about pip? pip3? Is there a pip3.6? I'm not entirely certain how I should be thinking about all these different Python installations.
You may want to use virtualenv so you can control your python environment, it's good practice. With virtualenv you can specify which version to use and your libraries are installed only for the project that needs it.
You can use python2 and python3 alongside just fine. However, if you want to use different minor versions of the python, for example 3.4 and 3.6, you have to set up virtual environment for each version. Look for the virtualenv or other solution.
I've just installed Anaconda on my macOS machine and it has changed my PATH so that now Python 3.6 is the default version (i.e. the Python 3.6 interpreter opens when I type python in the Terminal). I'm fine with this since this is the version I usually use, but I was wondering if there is the possibility of this messing up with the system functionalities relying on having 2.7 as default. I suppose that there will no problems since 2.7 is still in /usr/bin, but I would like to be sure.
I have been using Anaconda Python.
I had a problem with the default Python installed on my Mac OSX 10.11 at one point, because of the numpy package.
It was a problem for me when I tried to run a script in Anaconda Python which relies on a numpy version higher the Mac default version and I wasn't able to get it working using conda install, pip install, or by changing the PATH/PYTHONPATH.
I was able to install the package but Anaconda Python would not recognize the new version.
I ended up removing the entire numpy that came with the Mac. But I do not think this would be a problem in the other way (i.e., using mostly the Mac python but occasionally install other packages for Anaconda Python) because the default Python does not look at the Ancondoa package directory.
I have to use TensorFlow on my Windows 10 laptop, on which I have installed python 2.7, 3.2 and 3.4.2. I followed the instructions on the first answer here. I managed to install pip3 and tensorflow with the Ubuntu bash environment and I successfully tested TensorFlow on the command prompt. However, when I try to import it in my IEP environment (using Python 3.4), the module is not recognized. I am pretty new in managing python modules. What am I missing?
UPDATE: I found out that, when using Python via the ubuntu bash, the version is 3.4.3, but I never installed this version. Is there a way I can make it work with the versions I installed?
Looks like you are trying to make things complex to start with and having 3 (actually 4) python environment is making it even more harder if you are new to python. If you want to start using TF quickly and avoid platform specific problem, the quick route will be to remove most of platform 3.x installs and keep one if you really need 3.x otherwise you can do a lot with python 2.7. Once you have only 1 python environment, it will be very easy for you to manage and run faster. If you don't want to change anything and get you going with python do the following:
Install pip 8.1 or above
Install virtualenv for python 2.7 using pip - (This will help you to keep all the python specific modules within a specific folder)
Install TF for python 2.7 from https://www.tensorflow.org/get_started/os_setup
Use python 2.7 shell
If you run this command it will show which TF module you are using and where it is install (you must have TF installed):
python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'
I have installed iPython using pip in OS X 10.10, and it gave me the "ipython" and "ipython2" commands, which run great, but which use OS X's default python version 2.7.9. I downloaded and installed the latest release of Python3.4 and can load it with the command "python3," but cannot find a way to get iPython to use this version of python. The iPython Web site states the package can be used with python versions 3.3 and above, but I cannot find any instruction on how to change the default python version used.
So far I have found that the jupyter package for iPython has a kernel specification in /usr/local/share/jupyter/kernels/, which is just a folder called "python2" containing a json file that points to the system's python 2.7.6, but altering this to point to the new python3.4 installation does not work. My guess is this configuration is for the ipython notebook.
I've also tried the approach here: ipython reads wrong python version
In doing so I've duplicated the ipython2 command in /user/local/bin/ and edited it to use the python3 interpreter located at /Library/Frameworks/Python.framework/Versions/3.4/bin/python3, however, this gives me an error "ImportError: No module named 'IPython'," which suggests the python3 installation does not have ipython installed.
To tackle this, I've tried uninstalling ipython and reinstalling it using pip, but it just targets the system's Python 2.7 installation and does nothing for python3.
Does anyone know how to configure iPython to use a different python version, or even install a separate ipython installation for python3? Ultimately it would be nice to quickly switch back and forth depending on my needs.
I just found the answer. In essence, this stems from not understanding the python installation layout and how resources are separated between installed interpreters. It appears each python version will have its own repository of tools, and the current "pip" command I had installed on the system was mapped for use with python 2.7, so all libraries, tools, and other details it managed where available only to python 2.7. This included iPython.
I thought that installing python3 would make all these libraries available to the new interpreter by default, but it appears the system keeps them all separate (which makes sense). The main issue here was continuing to use "pip" which targeted the old installation, instead of the new "pip3" command included with python3. By using pip3 to reinstall iPython, I was able to get iPython3 installed properly.
Unfortunately this setup means needing to re-download other libraries, but that's not too difficult.
It might seem like a trivial issue in hindsight, but this had me completely stuck. I hope this helps someone else in this situation.
I am guessing that I am not the only one using non-system Python 2.7.2 for scientific computations on 6.2 PUIAS Linux (RedHat)). My Python 2.7.2 is installed in the sandbox and I call it with the command python2.7. When I need to execute scripts this is not the problem. However, I would like to use ipython instead default Python shell for interactive use. I added ipython using yum? When I start it, it defaults to system python. How do I force it to load python2.7?
Thanks a bunch!
IPython is a Python package. When you have multiple Pythons, you must (generally, barring PYTHONPATH hacks) install a package for a given Python. yum would only install it for the System Python, so you must install it separately for your own Python. The solution is to simply pip install ipython with your own Python (install distribute/pip first, if you haven't).
I am going to answer my own question. For people who are using Python for scientific computing on RedHat clones (PUIAS for example) the easiest way to get all they need is to use rpm package manager and Enthought Python Distribution (EPD for short). EPD installs everything in a sandbox so system tools which are based on an obsolete version of Python are not massed up. However, paths have to be adjusted for system or even easier on the user base so that the using shell invokes non-system tools.