Mac上的PyInstaller找不到libpython2.7 [英] PyInstaller on mac can't find libpython2.7

查看:351
本文介绍了Mac上的PyInstaller找不到libpython2.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PyInstaller 2.0创建Python脚本的二进制版本.我使用的是基本的"hello world" tkinter脚本,但导入了一些项目需要我测试Pyinstaller的依赖项.我在运行优胜美地10.10.5的Mac上. 这是我的脚本:

I am trying to make a binary version of a Python script using PyInstaller 2.0. I am using a basic "hello world" tkinter script but imported a few dependencies that i need for a project to test Pyinstaller out. I am on a mac running Yosemite 10.10.5. This is my script:

#!/usr/bin/env python
from Tkinter import *
import Tix
import tkMessageBox
from sklearn import linear_model, decomposition, preprocessing
from sklearn.preprocessing import Imputer
from sklearn.cross_validation import cross_val_score, cross_val_predict
from sklearn.neighbors import KDTree 
import numpy as np
import collections
import array
import math
import csv
from collections import OrderedDict
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
import matplotlib.dates as dates
from matplotlib.mlab import PCA
from mpl_toolkits.mplot3d import Axes3D
from scipy.stats import mode
import heapq
import sqlite3
from sqlite3 import datetime


root = Tk()

w = Label(root, text="Hello, world!")
w.pack()

root.mainloop()

运行完美.但是,当我使用

This runs perfectly. However when i go to build the binary using

$pyinstaller -w -F app.py 

然后我得到这个错误:

57665 ERROR: Can not find path ./libpython2.7.dylib (needed by //anaconda/bin/python)
Traceback (most recent call last):
  File "//anaconda/bin/pyinstaller", line 11, in <module>
    sys.exit(run())
  File "//anaconda/lib/python2.7/site-packages/PyInstaller/__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "//anaconda/lib/python2.7/site-packages/PyInstaller/__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "//anaconda/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 788, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "//anaconda/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 734, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "//anaconda/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 212, in __init__
    self.__postinit__()
  File "//anaconda/lib/python2.7/site-packages/PyInstaller/building/datastruct.py", line 178, in __postinit__
    self.assemble()
  File "//anaconda/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 543, in assemble
    self._check_python_library(self.binaries)
  File "//anaconda/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 626, in _check_python_library
    raise IOError(msg)
IOError: Python library not found: libpython2.7.dylib, Python, .Python
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.

* On Debian/Ubuntu, you would need to install Python development packages
  * apt-get install python3-dev
  * apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)

有人有什么想法我可以解决这个问题吗?当我使用基本的hello world示例而没有额外的依赖关系时,也会发生此错误.我在//anaconda/lib中有libpython2.7.dylib文件,我尝试使用

Does anyone have any ideas how i can fix this? This error also occurs when i am using the the basic hello world example without the extra dependancies. I have the libpython2.7.dylib file in //anaconda/lib and i tried to link it to usr/lib/ using

$sudo ln -s /usr/local/lib/libpython2.7.dylib //anaconda/lib/libpython2.7.dylib

但是它不能解决问题...

however it is not fixing the issue...

推荐答案

如果您像我这样通过pyenv使用python,则可能需要重新安装并启用共享访问xcode库,除非您之前做过.

If you are using python via pyenv like me, you might need to reinstall with enabling shared to access xcode libs unless you had done that earlier.

sudo env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 2.7

PS:我在达尔文(Darwin)上,但enable-shared仍然比enable-framework

PS: I am on Darwin but still enable-shared worked than enable-framework

实际上,下面的错误消息告诉我们该怎么做

In fact the message below error tells what to do

这篇关于Mac上的PyInstaller找不到libpython2.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆