ImportError: No module named bottle

后端 未结 5 1616
清酒与你
清酒与你 2021-01-11 18:26
$ sudo pip install bottle 
Downloading/unpacking bottle
  Downloading bottle-0.10.7.tar.gz (55Kb): 55Kb downloaded
  Running setup.py egg_info for package bottle
Ins         


        
5条回答
  •  萌比男神i
    2021-01-11 18:59

    It is recommended that you use a virtualenv with python in general but I'd say especially with web development.

    What happens when you use a virtualenv?

    $ sudo pip install virtualenv virtualenvwrapper
    $ sudo cat >> ~/.bashrc << EOF
    # virtualenvwrapper setup
    export WORKON_HOME=~/.virtualenvs
    export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages --python=python2.6'
    source /usr/local/bin/virtualenvwrapper.sh
    EOF
    $ source ~/.bashrc
    $ mkvirtualenv test
    $ pip install bottle
    $ python
    >>> import bottle
    

    Because I get this:

    $ python 
    Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) 
    [GCC 4.5.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import bottle
    Traceback (most recent call last):
      File "", line 1, in 
    ImportError: No module named bottle
    >>> 
    
    $ mkvirtualenv test
    Running virtualenv with interpreter /usr/bin/python2.6
    New python executable in test/bin/python2.6
    Also creating executable in test/bin/python
    Please make sure you remove any previous custom paths from your /home/hughdbrown/.pydistutils.cfg file.
    Installing setuptools.............................done.
    Installing pip...............done.
    virtualenvwrapper.user_scripts creating /home/hughdbrown/.virtualenvs/test/bin/predeactivate
    virtualenvwrapper.user_scripts creating /home/hughdbrown/.virtualenvs/test/bin/postdeactivate
    virtualenvwrapper.user_scripts creating /home/hughdbrown/.virtualenvs/test/bin/preactivate
    virtualenvwrapper.user_scripts creating /home/hughdbrown/.virtualenvs/test/bin/postactivate
    virtualenvwrapper.user_scripts creating /home/hughdbrown/.virtualenvs/test/bin/get_env_details
    
    $ pip install bottle
    Downloading/unpacking bottle
      Downloading bottle-0.10.7.tar.gz (55Kb): 55Kb downloaded
      Running setup.py egg_info for package bottle
    Installing collected packages: bottle
      Running setup.py install for bottle
        changing mode of build/scripts-2.6/bottle.py from 644 to 755
        changing mode of /home/hughdbrown/.virtualenvs/test/bin/bottle.py to 755
    Successfully installed bottle
    Cleaning up...
    
    $ python
    Python 2.6.6 (r266:84292, Mar 25 2011, 19:24:58) 
    [GCC 4.5.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import bottle
    >>> 
    

提交回复
热议问题