I've never used virtualenv, I'm working on Ubuntu 15.04 (remotely via ssh), and I've been told I can't make any changes to system the Pythons. Ubuntu 15.04 comes with Pythons 2.7 and 3.4.3, but I want Python 3.5 in my virtualenv. I've tried virtualenv -p python3.5 my_env and it gives The executable python3.5 (from --python=python3.5) does not exist, which I take to mean that it's complaining about the system not having Python 3.5. So, is it impossible to create a virtualenv with Python 3.5, if the system does not already have Python 3.5?
You can just install the latest version of python. You can also download and install the different versions in your user's home dir.
In case you are planning to have multiple versions installed manually. This is from the offical python README file.
Installing multiple versions
On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (--prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version. All files and directories installed using "make altinstall" contain the major and minor version and can thus live side-by-side. "make install" also creates ${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y. If you intend to install multiple versions using the same prefix you must decide which version (if any) is your "primary" version. Install that version using "make install". Install all other versions using "make altinstall".
For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others.
Once done that you can continue using the virtual environment for python using the python version of your choice.
Related
Python 3.7 is manually installed on my system, located in:
/Library/Frameworks/Python.framework
However, Homebrew still considers Python as a missing dependency for a formula which needs it (i.e., when typing brew missing).
How can I tell Homebrew that Python is already installed?
I'm not sure that brew will let you replace its own Python with another one. If a recipe specifies python as a dependency, that means brew's Python.
If you are concerned about brew's Python responding to the python command instead of your existing 3.7 installation this is best managed by adjusting your $PATH environment variable so that the directory containing the framework Python comes before /usr/local or wherever brew installs things on your machine. This might modify the Python that brew-installed software sees.
I'm trying to follow the instructions here but no matter what I do it seems to be stuck on using Python 2.7.1 which is causing me errors currently.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-osx.html
Attached is an image showing my logs of upgrading to the newest awsebccli but its still stuck saying 2.7.1 when it should say 3.6 (or newer)
What could I be doing wrong?
I want to note that I also installed the newest version of python3 and python via brew.
Here is the exact error I'm getting if it helps also.
You do not want to upgrade the default python 2.7x installation or the python 3.x installation available on linux or OSX. There are usually lots of other libraries and applications that depend on this default installation. When you want to use a specific version of python the approach is to rely on a virtual enviorenment.
virtualenv is a tool to create isolated Python environments.
You are then leaving the system installation untouched. Getting the hang of virtualenv is quite easy. Once you create it (a one off task). All you need is to activate it and then you can use it as you would normally use the default python interpreter. How to copy packages from one virtualenv (or the system installation) to another is discussed here:
Installing python3 in a python2 virtual environment
My Ubuntu uses python 3.4 as default python. Now I need to use python 2.7. The problems is it's difficult to clearly find out how to switch the default python version , and that numerous libs was installed with python 3.4- which makes python 2.7 unsupported.
Could anyone help me?
Ubuntu has something called Dead Snakes repository from where you can install any version of Python, maintained by Felix Krull.
https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes
The best practice is to
Install Python from deadsnakes PPA
Create a virtualenv for corresponding Python
virtualenv -p python2.7 my-venv
Then you use this virtualenv for further Python development and deployment
source my-venv/bin/active
Read more about Python virtual environments.
Do not change anything Python related in /usr/bin or symlinks. This breaks all your operating system packages depending on Python.
I encounter a problem with pip installation on linux. I've python 2.7 and 3.4, also Django in 1.7 installed. Currently I'm working on a project which uses different versions and I'm unable to install packages trough pip on python 2.7. Everything goes to directory of 3.4.
Is there any way to "force" pip to install packages in concrete version of python?
The usual, and recommended by most users, way of working with Django is to use a separate, virtual environment per project.
Use virtualenv to set up your Python 2.x environment and venv for Python 3.x. Both will install their own, local version of pip. Google lists lots of tutorials if you need help beyond the documentation.
I decided today I better download python 3.4. So I go to the python/downloads page and do that. Now I am trying to make a new virtualenv using my new python module, mkvirtualenv -p python3.4 sandbox, but I get an error that it can't find my python executable.
The executable /Users/croberts/python3.4 (from --python=/Users/croberts/python3.4) does not exist
This is understandable, but I can't figure out where it is. The old versions of python are in /usr/bin/ but the new one didn't get installed there. How do you search for where a program is using the terminal?
According to the ReadMe.txt bundled with the installer, Python installs default to /Library/frameworks/Python.framework. I just did a test install and it ended up here specifically:
/Library/frameworks/Python.framework/versions/3.4/Python
Unless you changed the settings on the installer, that's where it should live. (If you installed it from source, I'd assume you'd know where you put it.) Something to note is that if you use Homebrew (and possibly other OSX package managers like MacPorts, though I haven't used it), installing Python through the PPC installer will cause a warning:
Warning: Python is installed at /Library/Frameworks/Python.framework
Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.
So if you do use Homebrew (and it's great), it's best to simply use brew install python3, which will put it into /usr/local/bin. Then you can alias python (or python3) to that version, instead.