You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python3的PIP安装了Python2脚本,如何使其在Python3环境运行?

Fixing ever2simple to Run in Python 3 Environment

Got it, let's work through this issue together. That SyntaxError about missing parentheses in print is a dead giveaway—this script was built exclusively for Python 2, where print was a statement instead of a function (which requires parentheses in Python 3). Here are three reliable ways to get it working on your Windows 10 Python 3 setup:

1. Use Python's Official 2to3 Tool to Auto-Convert Syntax

This is the most straightforward method since it handles most Python 2 → 3 syntax changes automatically:

  • First, locate the source code folder of ever2simple. Since you installed it via Miniconda, it's probably in ...\Miniconda3\Lib\site-packages\ever2simple (look for a folder with .py files inside).
  • Open your Command Prompt or Anaconda Prompt, navigate to that folder with:
    cd "C:\Path\To\Miniconda3\Lib\site-packages\ever2simple"
    
  • Run the 2to3 tool with the -w flag to write changes directly to the files:
    2to3 -w .
    
    This will update all print statements to use parentheses, convert xrange to range, fix exception handling syntax (like except Error, e → except Error as e), and more.
  • After conversion, try running ever2simple.exe again—it should now work with Python 3.

2. Create a Python 2 Virtual Environment (No Code Changes Needed)

If you'd rather not modify the script, you can run it in a dedicated Python 2 environment (note: Python 2 is no longer supported, so use this only for legacy scripts):

  • Create a new conda environment with Python 2.7:
    conda create -n py27 python=2.7
    
  • Activate the environment:
    conda activate py27
    
  • Install ever2simple in this environment:
    pip install -U ever2simple
    
  • Run the script from this activated environment—it will use Python 2 and avoid the syntax error entirely.

3. Manually Update the Script's Syntax

If you prefer to tweak the code yourself (great for learning or small scripts):

  • Find all .py files in the ever2simple source folder (mentioned in method 1).
  • Open each file and replace every Python 2-style print statement:
    • Change print 'File does not exist: %s' % filepath → print('File does not exist: %s' % filepath)
    • Replace any other print statements without parentheses (e.g., print "Hello" → print("Hello"))
  • Check for other Python 2-specific syntax:
    • Replace except Exception, e → except Exception as e
    • Replace xrange() → range()
  • Save all changes, then run the script again.

内容的提问来源于stack exchange,提问作者trebi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:09:31