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

Anaconda环境运行特定.py文件报错:Python路径不存在?

Troubleshooting the "No such file or directory" Error for Your Eigenfaces Script

Hey there, let's tackle this issue step by step. The error clearly points to PyCharm trying to access a Python interpreter path that doesn't exist anymore—even though your Anaconda Python 2.7 and 3.6 environments seem to work fine. Here's what you can do to fix it:

1. Verify the actual path of your Anaconda Python 2.7 environment

First, let's confirm where your working Python 2.7 interpreter is actually located:

  • Open your terminal (Terminal app on macOS)
  • Activate your Python 2.7 environment with:
    source activate Py2.7
    
    (Note: If you're using a newer Conda version, you might need conda activate Py2.7 instead)
  • Run the following command to get the real interpreter path:
    which python
    
    Save this path—we'll use it later to update PyCharm's configuration.

2. Update PyCharm's Run Configuration

PyCharm is still referencing the old, broken path for your eigenfaces script. Let's fix that:

  • In PyCharm, click the run configuration dropdown in the top-right corner (it should show "eigenfaces" right now)
  • Select Edit Configurations...
  • In the window that pops up, locate your eigenfaces configuration in the left sidebar
  • Look for the Python interpreter field near the top. Check if the path matches what you got from the terminal.
    • If it doesn't, click the dropdown menu and select your Python 2.7 environment from the list.
    • If the environment isn't listed, click Show All... then the + button to add it manually, pasting the path you copied earlier.
  • Click Apply then OK to save the changes. Try running the script again.

3. Fix potential Anaconda environment corruption

If the path from the terminal doesn't match what PyCharm was using, your environment might have been damaged during the system crash. You can recreate the environment safely:

  • Deactivate the current environment first:
    source deactivate
    
  • Remove the old Py2.7 environment (optional but clean):
    conda remove -n Py2.7 --all
    
  • Create a fresh Python 2.7 environment:
    conda create -n Py2.7 python=2.7
    
  • Activate the new environment and reinstall any dependencies your project needs (e.g., if you have a requirements.txt file):
    source activate Py2.7
    pip install -r /Users/luka/Dropbox/Luka/Data Analysis/Data Science Nanodegree/P5/ud120-projects-master/pca/requirements.txt
    
  • Go back to PyCharm's run configuration and select this fresh environment as the interpreter.

4. Check Dropbox directory permissions

Since your project is stored in a Dropbox folder, there's a chance file permissions are preventing PyCharm from accessing the interpreter or script properly:

  • Try copying the entire pca directory to a local folder outside Dropbox (e.g., /Users/luka/Documents/pca)
  • Open the copied project in PyCharm and try running the script again. If it works, the issue was related to Dropbox's permissions or syncing.
  • If you want to keep using the Dropbox version, you can adjust permissions with this terminal command:
    chmod -R 755 /Users/luka/Dropbox/Luka/Data Analysis/Data Science Nanodegree/P5/ud120-projects-master/pca
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 08:58:17