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

Windows10重装oTree后执行otree startproject报错:项目名与模块冲突

Fixing "CommandError: 'otree' conflicts with existing Python module" when creating oTree project

Hey Sarah, I totally get how frustrating this must be—you’ve gone through all the reinstall steps and still hit this wall. Let’s break down what’s happening and fix it:

Why this error happens

The error isn’t about a folder in your C:\Users\Sarah directory—it’s about the oTree Python module itself installed in your Python’s site-packages folder. When you try to name your project otree, oTree (built on Django) gets confused: it can’t tell the difference between the project you’re trying to create and the existing oTree library it needs to run. Even if you deleted old folders, the installed oTree package is still present in your Python environment, triggering this conflict check.

Quickest solution: Use a different project name

Instead of otree, pick any unique name for your project—something like my_otree_study or otree_experiments works perfectly. Run this command instead:

C:\Users\Sarah>otree startproject my_otree_study
Include sample games? (y or n): y

This avoids the name clash entirely and should let you create the project with sample games without issues.

If you’re set on the otree name, you’ll need to isolate your project in a virtual environment (this keeps your project’s dependencies separate from your global Python install):

  1. Install virtualenv if you don’t have it:
    pip3 install virtualenv
    
  2. Create and activate a virtual environment in your user directory:
    virtualenv otree_env
    otree_env\Scripts\activate
    
  3. Install oTree inside this virtual environment:
    pip install otree==2.0.18
    
  4. Now try creating the project (note: even this might still trigger the conflict, since oTree is installed in the virtual env, but it’s worth a shot if you’re set on the name).

Double-check for lingering old files

You already did most of this, but just to be thorough:

  • Run pip3 list | findstr otree in Command Prompt to confirm only oTree 2.0.18 is installed.
  • Make sure there are no leftover virtual environments from your old oTree install that might be interfering (delete any old venv or otree_env folders if you find them).

Why this worked with the old oTree version

Older versions of oTree (or the Django version they used) didn’t have this strict name conflict check. The newer version added this safeguard to prevent confusing your project code with the core oTree library, which would cause import errors down the line.

Give the first solution a try—using a unique project name should get you up and running right away!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:47:41