【问题标题】:bad interpreter while attempting pip install flask尝试 pip install flask 时解释器错误
【发布时间】:2014-08-15 01:28:06
【问题描述】:

我确实在我的根目录中安装了 Flask,但是每当我更改目录并运行 virutalenv venv 以尝试通过 pip install flask 安装烧瓶时,我都会收到以下错误

bash: /home/phillipsk/rampup/sql/venv/bin/easy_install: /home/phillipsk/rampup/webapp/sql/venv/bin/python: bad interpreter: No such file or directory

这里是venv目录的内容

activate activate.csh activate.fish activate_this.py easy_install easy_install-2.7 pip pip2 pip2.7 python python2 python2.7

我可以跑/home/phillipsk/rampup/webapp/sql/venv/bin/python

python 解释器打开

Python 2.7.6

这里是 ls -l

/home/phillipsk/rampup/webapp/sql/venv/bin/python

-rwxr-xr-x 1 root root 3349512 Aug 15 13:11 /home/phillipsk/rampup/webapp/sql/venv/bin/python

这是我尝试运行pip install flask

>     (venv)phillipsk@phillips:~/rampup/webapp/sql/venv/bin$ pip install flask Downloading/unpacking flask Cleaning up... Exception: Traceback
> (most recent call last):   File
> "/home/phillipsk/rampup/webapp/sql/venv/local/lib/python2.7/site-packages/pip/basecommand.py",
> line 122, in main
>         status = self.run(options, args)   File "/home/phillipsk/rampup/webapp/sql/venv/local/lib/python2.7/site-packages/pip/commands/install.py",
> line 278, in run
>         requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)   File
> "/home/phillipsk/rampup/webapp/sql/venv/local/lib/python2.7/site-packages/pip/req.py",
> line 1153, in prepare_files
>         location = req_to_install.build_location(self.build_dir, not self.is_download)   File
> "/home/phillipsk/rampup/webapp/sql/venv/local/lib/python2.7/site-packages/pip/req.py",
> line 218, in build_location
>         _make_build_dir(build_dir)   File "/home/phillipsk/rampup/webapp/sql/venv/local/lib/python2.7/site-packages/pip/req.py",
> line 1527, in _make_build_dir
>         os.makedirs(build_dir)   File "/home/phillipsk/rampup/webapp/sql/venv/lib/python2.7/os.py", line
> 157, in makedirs
>         mkdir(name, mode) OSError: [Errno 13] Permission denied: '/home/phillipsk/rampup/webapp/sql/venv/build'
>     
>     Storing debug log for failure in /home/phillipsk/.pip/pip.log

sudo pip install flask 确实可以工作,但无论在运行任一 pip 命令后,我都会立即进入 python 解释器,import flask 没有成功

【问题讨论】:

  • 你能手动运行/home/phillipsk/rampup/webapp/sql/venv/bin/python吗?
  • 请显示ls -l /home/phillipsk/rampup/webapp/sql/venv/bin/python,如果它是一个符号链接,则显示ls -l作为它的目标。

标签: python flask


【解决方案1】:

作为临时解决方案,请尝试更改您的 venv 文件夹以及所有底层文件和文件夹的所有权:

sudo chown -R yourusername:yourusersgroup venv

然后重新激活 virtualenv 并尝试在没有 sudo 的情况下安装烧瓶。

顺便说一句。如果您在创建 virtualenvs 时使用 sudo,则不应该这样做。在没有 sudo 的情况下运行 virtualenv /path/to/virtualenv 并以普通用户身份登录,激活它,然后 pip install 东西。希望这会有所帮助。

作为旁注查看 virtualenvwrapper 项目。它可能会使您将来的事情变得更容易。 http://virtualenvwrapper.readthedocs.org/en/latest/

【讨论】:

    【解决方案2】:

    该目录归根用户所有, 你自己说的

    -rwxr-xr-x 1 root root 3349512 Aug 15 13:11 /home/phillipsk/rampup/webapp/sql/venv/bin/python
    

    就这样吧

    sudo pip install flask
    

    【讨论】:

    • 我上面说了,我sudo install后,进入python解释器,import flask还是不行
    猜你喜欢
    • 2015-12-27
    • 2018-08-31
    • 2020-12-11
    • 2015-09-01
    • 1970-01-01
    • 2014-08-25
    • 2018-12-13
    • 1970-01-01
    • 2019-08-18
    相关资源
    最近更新 更多