How to instruct Spyder3 to use a specific version of Python - python

I have both Python 3.5 and 3.6 installed on an Ubuntu Machine. Spyder3 uses 3.5 but pip3 uses 3.6 by default. Spyder gives an error message upon launch that a dependency is not met. So I have to either tell Spyder3 to use Python 3.6 or tell pip3 to use 3.5 but I don't know how.

No need to change any of those, you can install a package for a specific version of python by calling pip through python as a module like this:
python3.5 -m pip install tkinter
Replace python3.5 with the target version and tkinter with the target module that is required.
Hope this helps!

Related

Python version on RPI 3.8.2 but default is 3.5.3 issues

I have installed version 3.8.2 on my RPI because i previously had versions 2.7 and 3.5.3 installed. When I try to install stuff like ipython i get this: ERROR: Package 'ipython' requires a different Python: 3.5.3 not in '>=3.6'.
Tried various stuff and nothing works. Modified paths, installed 3.8.2 multiple times, tried to remove 3.5.3. Nothing works. It appareas the base version is 3.5 but I need it to be 3.8.2 and no idea how to do that.
Also when i try to run a python file I get the error that it cannot find numpy, and I have numpy installed in all versions.
Struggled for over a day to fix it and nothing. Can anybody help?
versions of python on RPI
Python is a requirement of Debian, hence uninstalling the version present by default is not recommended (it basically breaks the system).
If you need to run python 3.8 you should install it manually and call it with
python3.8 what_you_need.py
Also for pip:
python3.8 -m pip install what_you_need
I also suggest you to have a look to virtual environments:
https://docs.python.org/3/library/venv.html
https://github.com/pypa/pipenv

Homebrew not installing the correct version of Python

I was trying to install Python 3.7 using homebrew with "brew install python". When I check the version of python installed, I get python 2.7.10. Anyone know how to fix this?
Most likely you need to call python 3.7 commands with
python3
and install packages with
pip3
as well, also check your $PATH configuration, as is it usually takes the OSx python as default in Macs

How to uninstall Python 2.7 and keep Python 3.4?

I think my title is pretty self-explanatory.
I want to uninstall Python 2.7 and keep Python 3.4 intact. Is this easy to do? I found a couple of tutorials about how to uninstall Python, but I don't want to uninstall the entire thing. Also, I am running Spyder (Python 3.6). This should work just fine after I get rid of 2.7, right. The reason I am asking all of this is because I installed pandas_datareader and apparently it went to 2.7, but I really wanted it on 3.4. Finally, I'm assuming, after I unistall 2.7, and run this 'pip install pandas_datareader' it will go to 3.4, right.
I can't seem to control where the install goes.
Instead of using:
pip install <module>
you can use the following to install the module which will install it to python-3.x (as long as python points to your python-3.x directory in your PATH):
python -m pip install <module>
Or alternatively, you can use pip3 to install it directly to python-3.x.
To use pip3, you need to navigate to:
C:\path\to\python\Scripts\pip3
and then run it as:
pip3 install <module>
and it will be installed to python-3.x rather than python-2.x.
If you need to uninstall a Python just use Windows' Add/Remove programs and run the uninstaller for that specific version.
Later versions of Python include PyLauncher (py.exe) and install it to C:\Windows which is always in the path. Use it to control which Python to run and which pip to run if you have several installed. If you use this you won't have to add a specific version of Python or its Scripts directory (where pip.exe is) to your path.
Examples:
py -3 -m pip install <package> # Use latest Python 3 installed.
py -2 -m pip install <package> # Use latest Python 2.
py -3.3 # Run Python 3.3
py -2.7-32 # Run 32-Python 2.7 on a 64-bit OS.
py # Run default Python (usually latest 3.x)
The PY_PYTHON environment variable can override the default.
See also: Python Launcher for Windows

Install Python 3.5 on Mac for IntelliJ IDEA / PyCharm

I'm using a third-party Python package that supports Python 3.5, but not 3.6. I've got Python 2.7 installed from my OS vendor (it's a Mac), and Python 3.6 installed through homebrew.
What's the best way for me to install 3.5 and configure IntelliJ IDEA (using its Python plugin, so it's basically equivalent to PyCharm) to use it?
You can install as many Python distributions as you want and they all located in /Library/Frameworks/Python.framework/Versions. However, pip3 will only be linked to the last python distribution you installed, not the latest. For example, in my case, my pip3 is the module in python3.5 because I installed it after 3.6. If you want to use a package for a specific version, run $ python3.x -m package. python3.6 -m pip install, for example.

Django is installing to the wrong python version

I had python 2.6 and I downloaded Django. I found that python 2.6 throws errors when trying to run django, so I downloaded python 2.7. Now, typing python in the terminal runs 2.7 but the django library isn't in the 2.7 folder. So I uninstalled django using:
sudo pip uninstall django
and that worked just fine. When i used the command:
sudo pip install django
it installed into the python 2.6 instead of python 2.7.
How can I install django into python 2.7 instead of python 2.6?
(I am running a MacBook Pro on 1.6, and I was told to not uninstall the base version of python because so many of the systems use 2.6)
You need to install pip for python2.7. If it's installed, you should be able to see it using which pip-2.7.
It's better not to touch system python. Use homebrew to install your own.
The problem is that you are running pip from your default Python installation (2.6), read this: How to run multiple python version on Windows, maybe answers give you how to solve in your OS X.
You can view the version of your default Python installation by executing python -V, there is a way to specify which version to use when you execute python, in Linux you can create an alias (alias python=python2.7) in your $HOME/.bash_profile, OS X must have something similar, then install pip using your preferred version.
BTW, It's recommended to use virtualenv

Categories