Python 设法打破了我的静脉;有可能修复吗?
我设法破坏了我的一个虚拟环境。我想我是通过使用Python 设法打破了我的静脉;有可能修复吗?,python,macos,Python,Macos,我设法破坏了我的一个虚拟环境。我想我是通过使用pip安装pycrypto并使用easy\u install卸载它来实现的 这就是我在venv中运行python时得到的结果 filip@dratmac:~/PycharmProjects/Project-Marketplace2/backend/odb/helper_objects$ python Traceback (most recent call last): File "/System/Library/Frameworks/Python
pip
安装pycrypto
并使用easy\u install
卸载它来实现的
这就是我在venv中运行python时得到的结果
filip@dratmac:~/PycharmProjects/Project-Marketplace2/backend/odb/helper_objects$ python
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 62, in <module>
import os
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 49, in <module>
import posixpath as path
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 17, in <module>
import warnings
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.py", line 8, in <module>
import types
File "types.py", line 1, in <module>
import json
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 108, in <module>
from .decoder import JSONDecoder
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 3, in <module>
import re
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 280, in <module>
import copy_reg
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.py", line 7, in <module>
from types import ClassType as _ClassType
ImportError: cannot import name ClassType
filip@dratmac:~/PycharmProjects/Project-Marketplace2/backend/odb/helper_objects$
如何解决此问题?您不应将文件命名为
types.py
,因为存在同名的标准库模块(导入类型
)
因此,Python试图将其作为一些标准库代码的一部分导入,但现在它实际上导入了本地types.py
文件,而不是它所期望的模块
因此,当您将types.py重命名为其他名称时,问题应该得到解决。可能重复的
Last login: Tue Apr 7 22:30:08 on ttys005
filip@dratmac:~$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>