python 2.7 OSX 10.10包问题

时间:2014-12-10 11:21:01

标签: macos python-2.7 pip homebrew osx-yosemite

我正在使用: mac osx 10.10.1

昨天我开始使用我通常使用的相同软件包来获取错误。 几个小时后我决定从我的mac中删除python

我按照以下说明再次安装了python: http://docs.python-guide.org/en/latest/starting/install/osx/#install-osx (我使用HomeBrew安装了python 2.7的坚果shell)

from the shell:
$python
Python 2.7.8 (default, Oct 19 2014, 16:02:00) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from the shell:
$ which python
/usr/local/bin/python

from the shell:
$ which -a python
/usr/local/bin/python
/usr/local/bin/python

我安装了pip 我使用$ pip install命令安装了几个pkgs

当我尝试导入openpyxl时 我明白了:

import openpyxl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/openpyxl/__init__.py", line 27, in <module>
from openpyxl.workbook import Workbook
File "/usr/local/lib/python2.7/site-packages/openpyxl/workbook/__init__.py", line 25, in <module>
from .workbook import *
File "/usr/local/lib/python2.7/site-packages/openpyxl/workbook/workbook.py", line 11, in <module>
import threading
File   
"/usr/local/Cellar/python/2.7.8_2/Frameworks/
Python.framework/Versions/2.7/lib/python2.7/threading.py", 
line 14, in <module>
from time import time as _time, sleep as _sleep
ImportError: cannot import name time
你可以帮帮我吗? 谢谢 d

其他信息:

同时我试图做同样的事情来解决问题 (我没有解决它)

基本上我安装了virtualenv 我创建了一个基本的虚拟环境 我有一个新的python文件夹和所有的pkgs

(venv_002)danielepemys-MacBook-Pro:my_python_virtualenv danielepemy$ which python
/Users/danielepemy/my_python_virtualenv/venv_002/bin/python

一切看起来都很好,python工作,pip工作pkgs列在虚拟环境

(venv_002)danielepemys-MacBook-Pro:my_python_virtualenv danielepemy$ pip list

pip (1.5.6)

setuptools (3.6)

wsgiref (0.1.2)

XlsxWriter (0.6.4)


when I run a simple test script with XlsxWriter I get:

python ..//internet_speed_test_002.py 

Traceback (most recent call last):

  File "..//internet_speed_test_002.py", line 28, in <module>

    excel_file.close()

  File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/workbook.py", line 286, in close

    self._store_workbook()

  File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/workbook.py", line 509, in _store_workbook

    xml_files = packager._create_package()

  File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/packager.py", line 142, in _create_package

    self._write_core_file()

  File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/packager.py", line 325, in _write_core_file

    core._assemble_xml_file()

  File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 57, in _assemble_xml_file

    self._write_dcterms_created()

  File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 122, in _write_dcterms_created

    date = self._localtime_to_iso8601_date(date)

  File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 76, in _localtime_to_iso8601_date

    return date.strftime("%Y-%m-%dT%H:%M:%SZ")


AttributeError: 'module' object has no attribute 'struct_time'

1 个答案:

答案 0 :(得分:0)

您当前目录中是否有名为time.pytime.pyc的文件?如果是这样,请重命名或删除它们(.pyc文件可以简单地删除。)