1,mac自带的python是2.7版本,我们需要按照python3,这样在terminal下可以直接使用,但是编译打包的时候会默认使用python2.7

解决办法:安装virtualenv,一个管理包的虚拟环境。

$ [sudo] pip install virtualenv
如果遇到错误:IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'

解决:sudo chmod +a 'user:lichanghong allow add_subdirectory,add_file,delete_child,directory_inherit' /Library/python/2.7/site-packages/

1)virtualenv 的使用可以参考:http://www.cnblogs.com/tk091/p/3700013.html

  创建python3环境: virtualenv -p /usr/local/Cellar/python3/3.5.1/bin/python3  py

  启动:source activate

 关闭:deactivate
2,适配python2,3

import sys

if sys.version_info < (3, 0):

# Python 2

import Tkinter as tk

else:

# Python 3

import tkinter as tk

3,If you build with virtualenv --system-site-packages ENV
-------------------以上尝试能够行得通,但是在python3的环境下在pyinstaller里一直找不到tkinter,故改用cx_freeze

安装: pip3 install cx_freeze
cxfreeze hello.py --target-dir dist 编译到了dist
在cmd窗口输入cxfreeze-quickstart可以自动生成setup.py

例如:setup.py:
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = ["os"], excludes = ["tkinter"])

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [
Executable('my.py', base=base, targetName = 'my.app')
]

setup(name='testproj',
version = '1.0',
description = 'testproj 1.0 desc',
options = dict(bdist_exe = buildOptions),
executables = executables)

python setup.py bdist_msi
On Mac OS X, you can use bdist_dmg to build a Mac disk image.



python3学习笔记及常见问题的更多相关文章

  1. Python3学习笔记(urllib模块的使用)转http://www.cnblogs.com/Lands-ljk/p/5447127.html

    Python3学习笔记(urllib模块的使用)   1.基本方法 urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None,  ...

  2. Python3学习笔记 - 准备环境

    前言 最近乘着项目不忙想赶一波时髦学习一下Python3.由于正好学习了Docker,并深深迷上了Docker,所以必须趁热打铁的用它来创建我们的Python3的开发测试环境.Python3的中文教程 ...

  3. python3学习笔记(7)_listComprehensions-列表生成式

    #python3 学习笔记17/07/11 # !/usr/bin/env python3 # -*- conding:utf-8 -*- #通过列表生成式可以生成格式各样的list,这种list 一 ...

  4. python3学习笔记(6)_iteration

    #python3 学习笔记17/07/10 # !/usr/bin/env python3 # -*- coding:utf-8 -*- #类似 其他语言的for循环,但是比for抽象程度更高 # f ...

  5. python3学习笔记(5)_slice

    #python3 学习笔记17/07/10 # !/usr/bin/env python3 # -*- coding:utf-8 -*- #切片slice 大大简化 对于指定索引的操作 fruits ...

  6. Python3学习笔记01-环境安装和运行环境

    最近在学习Python3,想写一些自己的学习笔记.方便自己以后看,主要学习的资料来自菜鸟教程的Python3教程和廖雪峰官方网站的Python教程. 1.下载 1)打开https://www.pyth ...

  7. python3学习笔记(9)_closure

    #python 学习笔记 2017/07/13 # !/usr/bin/env python3 # -*- conding:utf-8 -*- #从高阶函数的定义,我们可以知道,把函数作为参数的函数, ...

  8. python3学习笔记(8)_sorted

    # python学习笔记 2017/07/13 # !/usr/bin/env python3 # -*- coding:utf-8 -*- #python 内置sorted()函数 可以对list进 ...

  9. python3学习笔记(4)_function-参数

    #python学习笔记 17/07/10 # !/usr/bin/evn python3 # -*- coding:utf-8 -*- import math #函数 函数的 定义 #定义一个求绝对值 ...

随机推荐

  1. [springMvc] 源码分析笔记(二)

    1.SpringMvc 中核心Servlet的继承结构图 2.HttpServletBean public abstract class HttpServletBean extends HttpSer ...

  2. python线程condition条件锁应用实例

    import time import threading # 吃火锅鱼丸 guo = [] suo = threading.Condition() #条件锁 # 生产者负责生产 class Produ ...

  3. test--2

    $(function () {   if (isLogined && !c_has_follwed) {   $.ajax({   url: "/mvc/Follow/Fol ...

  4. python 网络编程(Socket)

    # from wsgiref.simple_server import make_server## def RunServer(environ,start_response):# start_resp ...

  5. [Codeforces543D]Road Improvement

    Problem 刚开始每条边都是坏的,现在要选取一个点使得其他点到这个点的路径上最多只有一条坏路,问至少要修好多少条边 Solution 如果以1为根,那么是个简单的树形DP 设根从u转移到v,那么u ...

  6. python基础第一天 3.27

    # #作业1# 猜年龄,可以让用户猜三次!age = 25user_guess = int(input("input your guess"))   age = 25count = ...

  7. min_25筛题目总结

    看了网上众多博客后,我才发现,实现min_25只有脑子,没有代码. 当然可能是我太ruo了. min_25是一种想法,不是算法. 不要尝试套模板,因为很多题目并没有什么用. 最重要的一点,g不要看成是 ...

  8. 使用walle部署laravel的时候问题记录

    1.使用walle部署laravel的时候检出后执行composer update提示 [RuntimeException]The HOME or COMPOSER_HOME environment ...

  9. 记录这段时间java编程的小知识点

    记录这段时间java编程的小知识点 eclipse项目导入中文乱码 eclipse左侧目录结构变动 eclipse代码段左右移动 按tal键,是整体右移. 按shift  table 同时按,是整体左 ...

  10. php实现遍历目录

    用递归方法实现目录的遍历: <?php header("Content-type: text/html; charset=utf-8"); date_default_time ...