在Mac OS上安装我自己创建的python包时,我收到了下面提到的错误的编组数据错误。
deveshs-MacBook-Pro:mycli devesh$ sudo python setup-4.0.py install
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
/usr/bin/python -E -c pass
TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing requirements to mycli.egg-info/requires.txt
writing cftcli.egg-info/PKG-INFO
writing top-level names to mycli.egg-info/top_level.txt
writing dependency_links to mycli.egg-info/dependency_links.txt
writing entry points to mycli.egg-info/entry_points.txt
reading manifest file 'mycli.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'mycli.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.10-intel/egg
running install_lib
running build_py
copying mycli.egg-info/PKG-INFO -> build/bdist.macosx-10.10-intel/egg/EGG-INFO
copying mycli.egg-info/SOURCES.txt -> build/bdist.macosx-10.10-intel/egg/EGG-INFO
copying mycli.egg-info/dependency_links.txt -> build/bdist.macosx-10.10-intel/egg/EGG-INFO
copying mycli.egg-info/entry_points.txt -> build/bdist.macosx-10.10-intel/egg/EGG-INFO
copying mycli.egg-info/requires.txt -> build/bdist.macosx-10.10-intel/egg/EGG-INFO
copying mycli.egg-info/top_level.txt -> build/bdist.macosx-10.10-intel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
Traceback (most recent call last):
File "setup-4.0.py", line 42, in <module>
"requests==2.4.3",
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Python/2.7/site-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/Library/Python/2.7/site-packages/setuptools/command/install.py", line 109, in do_egg_install
self.run_command('bdist_egg')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Python/2.7/site-packages/setuptools/command/bdist_egg.py", line 208, in run
os.path.join(archive_root, 'EGG-INFO'), self.zip_safe()
File "/Library/Python/2.7/site-packages/setuptools/command/bdist_egg.py", line 244, in zip_safe
return analyze_egg(self.bdist_dir, self.stubs)
File "/Library/Python/2.7/site-packages/setuptools/command/bdist_egg.py", line 354, in analyze_egg
safe = scan_module(egg_dir, base, name, stubs) and safe
File "/Library/Python/2.7/site-packages/setuptools/command/bdist_egg.py", line 391, in scan_module
code = marshal.load(f)
ValueError: bad marshal data (unknown type code)
我尝试从setuptools目录中删除所有* .pyc文件。 请指导如何解决此问题。 感谢。
答案 0 :(得分:0)
首先我认为问题出在文件名上,该文件名应仅为setup.py
,但它也会在sudo python setup.py install
时出现同样的错误。
我发现的解决方法是首先创建源代码分发。 see documentation here
以下是可以正常使用的脚本,并将我们从上述问题中解脱出来。
cp -f setup-4.0.py setup.py
python setup.py sdist --format=zip,gztar
sudo pip install dist/mycli-4.0.tar.gz
rm setup.py
要卸载:sudo pip uninstall mycli
希望它能帮助一些Mac用户。谢谢。