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

如何在Processing中导入Python 3.7?Mac端当前用Python 2求助

Switching Processing on Mac from Python 2 to Python 3.7

Hey there, let's work through getting your Processing project on Mac switched over to Python 3.7—this is a common pain point with older Processing.py setups, so here’s what’s worked for me and other developers:

First: Confirm Python 3.7 is properly installed

  • Open your Terminal and run python3.7 --version. If it returns a 3.7.x version number, you’re good to go. If not, grab the official Python 3.7 installer for Mac (make sure to pick the right build for your chip—Intel or Apple Silicon) and install it. Don’t forget to check the "Add Python 3.7 to PATH" box during installation.
  • Next, get the full path to your Python 3.7 executable by running which python3.7 in Terminal. You’ll get something like /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7—copy this path, you’ll need it later.

Update Processing.py to use Python 3.7

Processing’s Python mode (Processing.py) relies on a configured Python interpreter path, so we’ll point it to your 3.7 installation:

  • Open Processing, and make sure you’re in Python mode (if you don’t have it installed yet, grab it from the Mode Manager via the dropdown in the top-right corner).
  • Open Processing’s preferences: go to Processing > Preferences in the top menu bar.
  • Look for the Python Path setting (it’s usually under a dedicated "Python" tab). Paste the full Python 3.7 path you copied earlier into this field.
  • Restart Processing, then create a quick test sketch:
    import sys
    print(sys.version)
    
    Run the sketch—if the console outputs a 3.7.x version, you’ve successfully switched!

Fixing dependency & compatibility issues

If you hit errors after switching:

  • Install any required libraries using Python 3.7’s pip. Run this in Terminal, replacing [library-name] with your actual library (like numpy):
    /Library/Frameworks/Python.framework/Versions/3.7/bin/pip3.7 install [library-name]
    
  • You’ll also need to update any Python 2-specific syntax in your code:
    • Replace print "hello" with print("hello")
    • Swap xrange() with range()
    • Fix any iteritems() calls to items() (for dictionaries)

Alternative: Use a Conda environment (if you prefer)

If you manage Python versions with Conda, this works too:

  • Create a dedicated Python 3.7 environment:
    conda create -n processing-py37 python=3.7
    
  • Activate the environment:
    conda activate processing-py37
    
  • Get the environment’s Python path with which python, then paste that into Processing’s Python Path setting.
  • Install libraries directly in this Conda environment using pip install [library-name]

If you’re still stuck, make sure you’re using a recent version of Processing (4.x is ideal)—older Processing releases have spotty Python 3 support.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.07 09:33:13