How to choose Python Intrepreter version among installed? - python

both versions of python interpreter are installed on my pc but when I need to call pip on command line, it's downloading libraries for 3.7 and don't really know how can I code on Python 3.6.
Need to load a library from MATLAB (matlab.engine library) to run a Simulink model on Python. it's impossible to install for Python 3.7. All that is why I try to work on Python 3.6.
by the way, I am coding on Notepad++ as editor.
Problem solved;
Although they both are on path,command line always has worked for 3.7. I changed name of 3.6 interpreter as python3.exe and call 'python3' it worked very well !

Related

After switching to Python 3.6.5_1, the displayed version is still 3.7.2

I am trying to use Python 3.6.5_1 for OpenCV, so I have switched Python versions using "brew switch python 3.6.5_1", but after checking my current version of Python using "python --version", I apparently am still using Python version 3.7.2. Any solutions? By the way, this is the tutorial I am following: https://www.pyimagesearch.com/2018/08/17/install-opencv-4-on-macos/
Check your python path to see where your python executable is being stored---which python in terminal. I bet it's still pointing to your 3.7.2 directory's python.
If you are switching between python versions, virtualenv can be used to initialize isolated environment with a specific python version.
virtualenv -p [preferred-python-version] open_cv_project_env

Is there any possibile issue in having Anaconda Python 3.6 as default Python version in macOS?

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.

Python module installed on Windows 10 with Ubuntu bash is not recognized

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)))'

How do I change the kernel/python version for iPython?

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.

Multiple Python versions in one computer (windows 7)

I have two versions of Python installed in my computer, Python 3.4 and Python 2.7, and I use both of these installations. When I run a script, how do I choose which versions I want to use? May I rename the names of the executables for that (Python.exe -> Python27.exe)?
Thanks.
Both python 2.7 and python 3 coexist on one machine happily.
If you name the scripts .py for those you would like to run with python 2.3 and .py3 for those that you would like to run with python3 then you can just invoke the scripts by typing their names or by double clicking. These associations are set up by default by the installer.
You can force the python version on the command line, assuming both are on the path by typing python or python3 for any script file regardless of the extension.
It is also worth looking at virtualenv for your testing.
N.B. For installing from pypi you can use pip or pip3 and the install for the appropriate version will be done.
I am using a 32-bit and a 64-bit version of Python 2.7.6 on the same Windows machine, and the solution to that was to use Winpython for the 64-bit version, which is portable.
The downside is that doubleclicking in the file manager will attempt to run a Python script with the 32-bit version (which is a non-portable installation), but I'm mostly writing and running scripts inside Spyder, and there's one version of it with each Python installation. Both have independent Pythonpaths, and have never had any problems with each other. Winpython is aimed at scientific use, though, so it may not come with all the libraries you may need.

Categories