After upgrading to ActivePython 2.7.5.6 from ActivePython 2.7.3, bbfreeze fails with several import errors, e.g. ImportError: cannot import name MAXREPEAT. I traced the issue and it is with wrong Python version/installation picked by bbfreeze. It is weired that currently there are two system Python installations:
bash-3.2$ python
Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
and:
ash-3.2$ /usr/bin/python2.7
Python 2.7 (r27:82500, Sep 24 2010, 08:01:50)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
and a local installation:
bash-3.2$ ActivePython-2.7/bin/python
ActivePython 2.7.5.6 (ActiveState Software Inc.) based on
Python 2.7.5 (default, Sep 16 2013, 23:05:39)
[GCC 4.0.2 20051125 (Red Hat 4.0.2-8)] on linux2
but embeded python compler in bbfreeze give a different one, i.e. none of a bove:
bash-3.2$ bin/py
Python 2.7.1 (r271:86832, Dec 5 2010, 11:36:33)
[GCC 4.0.2 20051125 (Red Hat 4.0.2-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(MyConsole)
I even don't know where this Python 2.7.1 is installed! Any idea how to force bbfreeze to use the local python directory. I already used virtualenv, but didn't work.
Thanks.
#AsoAgile
I downgraded ACtivePython to 2.7.3 and reinstalled bbfreeze and it worked. So bbfreeze turned out to be not supporting ActivePython 2.7.5.
Related
I have some python scripts (python 3.5 based) which I want to call using R/RStudio. For the same, I am using rPythonpackage. Whenever I make a call to these scripts, RStudio uses python 2.7.10 as shown
import sys
print(sys.version)
2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
but I want to use python 3.5.
On my system, python 3.5 is installed and is set to default as shown below
HaroonMacBook:~ haroonr$ python
Python 3.5.2 |Anaconda custom (x86_64)| (default, Jul 2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
I tried to force python 3.5 in RStudio by using:
Sys.setenv(PATH=paste("/Volumes/MacintoshHD2/Users/haroonr/anaconda/bin",Sys.getenv("PATH"),sep=":"))
Accordingly, I do get
> Sys.getenv("PATH")
[1] "/Volumes/MacintoshHD2/Users/haroonr/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin:/opt/local/bin"
What all are the other ways to force Rstudio for using python 3.5
UPDATE 1:
I call python code using following statements from RStudio:
library(rPython)
Sys.setenv(PATH=paste("/Volumes/MacintoshHD2/Users/haroonr/anaconda/bin",Sys.getenv("PATH"),sep=":"))
python.load("/Volumes/MacintoshHD2/Users/haroonr/Desktop/demo2.py", get.exception = TRUE)
I would like to execute Python scripts using the Python/C API (I am using Mac OS X Mavericks, Xcode). Since multiple Python distributions are installed on my machine (System, Homebrew, several virtualenvs), how can I define which to use?
You can define which one to use either:
by specifying the fullpath to the executable ;
or with different aliases.
For example, I have both Python 2.7 and Python 3.2 on this machine:
$ python
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ python3
Python 3.2.3 (default, Jul 23 2012, 16:48:24)
[...]
$ /usr/bin/python2.7
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[...]
$ /usr/bin/python3.2
Python 3.2.3 (default, Jul 23 2012, 16:48:24)
[...]
When I type "python" into a terminal, I get this:
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
I am unsure whether this means Ananconda has been successfully installed?
To install the Anaconda-1.9.0-MacOSX-x86_64.sh, open Terminal and run
/bin/bash Anaconda-1.9.0-MacOSX-x86_64.sh
The installer will ask a series of questions and install it in a prefix you determine. When you are done, close the Terminal and open it again. (This is so that your Terminal picks up the new PATH which points to the prefix/bin.)
When it is installed you should see something like the following in the Terminal:
$ python
Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Nov 11 2013, 10:49:09)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
I've installed Python via MacPorts. According to this question, the files in /opt/local/bin should run the "correct" Python version. However, all those files are symlinks to:
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/
Running them directly from that folder (using no symlinks) runs an Apple build of Python!
Python 2.6.6 (r266:84292, Jan 6 2011, 13:25:25)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
For comparison, running /usr/bin/python shows a slightly different version:
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
They're both Apple builds! How do I install the correct version?
There are no "Apple builds" except the system Python (which is 2.6.1 on Snow Leopard, afai can deduce). The ports install seems to have worked as expected in this case. The reference to Apple is a reference to which GCC that was used.
I think it is running the build you want.
macports install every thing in /opt/local. So /opt/local/bin/python is a macport distribution.
/usr/bin/python is pre-install python distribution that comes with mac os x.
The following line, is an information about gcc build which is used for building macport python distribution.
[GCC 4.2.1 (Apple Inc. build 5664)]
If you have multiple versions of macport python installed, you can select the version using python-select
sudo port install python-select sudo
python-select python26
Also to ensure that you use macport python you could add the following to the PATH
export PATH=/opt/local/bin:$PATH
I would appreciate it if somebody running the final version of Snow Leopard could post what version of Python is included with the OS (on a Terminal, just type "python --version")
Thanks!
It ships with both python 2.6.1 and 2.5.4.
$ python2.5
Python 2.5.4 (r254:67916, Jul 7 2009, 23:51:24)
$ python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
bot:nasuni jesse$ python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Probably the biggest reason I went and upgraded this morning, it's not 2.6.2, but it's close enough.
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/python.1.html
Python 2.6.1
(according to the web)
Really good to know :)
You can get an installer for 2.6.2 from python.org, no reason to go without.