Windows10重装oTree后执行otree startproject报错:项目名与模块冲突
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 really want to use "otree" as the project name (not recommended)
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):
- Install virtualenv if you don’t have it:
pip3 install virtualenv - Create and activate a virtual environment in your user directory:
virtualenv otree_env otree_env\Scripts\activate - Install oTree inside this virtual environment:
pip install otree==2.0.18 - 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 otreein 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
venvorotree_envfolders 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

