10
$ 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
Installing collected packages: bottle
  Found existing installation: bottle 0.10.7
    Uninstalling bottle:
      Successfully uninstalled bottle
  Running setup.py install for bottle
    changing mode of build/scripts-2.6/bottle.py from 640 to 755
    changing mode of /usr/local/bin/bottle.py to 755
Successfully installed bottle

>>> help('modules')
blahblah
bottle
blahblah

$ ls /usr/local/lib/python2.6/dist-packages/
bottle-0.10.7.egg-info  bottle.py  bottle.pyc

but

$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bottle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named bottle

wtf??? Ubuntu 10.10

SOLUTION: # chmod -R 775 /usr/local/lib/python2.6/dist-packages/ is help for me. Thanks for all.

strangeman
  • 519
  • 1
  • 5
  • 19
  • 1
    What does `which python` say? – Russell Borogove Feb 03 '12 at 00:56
  • >>> print sys.path ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/Numeric', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode'] – strangeman Feb 03 '12 at 01:25
  • Hmmm. PIP install bottle to wrong location? – strangeman Feb 03 '12 at 01:26
  • No, `/usr/local/lib/python2.6/dist-packages` is present. – Felix Yan Feb 03 '12 at 01:30
  • # chmod -R 775 /usr/local/lib/python2.6/dist-packages/ is help for me. Thanks for all. – strangeman Feb 03 '12 at 03:37
  • If you solved your problem, write your own answer and accept it. This way, the question won't appear on the unanswered list. – Helgi May 20 '12 at 10:45

5 Answers5

2

What ended up working for me was:

chmod -R 775 /usr/local/lib/python2.6/dist-packages/ 
starrify
  • 14,307
  • 5
  • 33
  • 50
strangeman
  • 519
  • 1
  • 5
  • 19
2

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 "<stdin>", line 1, in <module>
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
>>> 
hughdbrown
  • 47,733
  • 20
  • 85
  • 108
  • Traceback (most recent call last): File "", line 1, in ImportError: No module named virtualenvwrapper.hook_loader virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly. – strangeman Feb 03 '12 at 02:15
  • I think, i need remove all: pip, virtualenv, bottle etc, and reinstall them. :) – strangeman Feb 03 '12 at 02:17
  • Yes, you need to add to your ~/.bashrc: `export WORKON_HOME=~/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh` – hughdbrown Feb 03 '12 at 02:21
  • You're running Ubuntu and you have no ~/.bashrc? Sourcing .bashrc fails with an error? – hughdbrown Feb 03 '12 at 13:03
  • Or maybe virtualenvwrapper is being installed into `/usr/local/bin` and you have a general problem installing into `/usr/local` that is not fixed by chmod-ing `/usr/local/lib/python2.6/dist-packages`. – hughdbrown Feb 03 '12 at 17:24
0

I know I'm late to the party - but I was having a problem using python command and my bottle.py module being located in my 3.x lib directory.

I just tossed a symlink from bottle.py in my python3.x to my current 2.x directory as such:

sudo ln -s ~/.local/lib/python3.5/site-packages/bottle.py /usr/local/lib/python2.7/dist-packages/bottle.py

Obviously change the version numbers to match your directory structure!

MJHd
  • 166
  • 1
  • 10
0

Check to see if you can run python3.

JMP
  • 557
  • 1
  • 6
  • 17
0

Please, check the following documentation on PYTHONHOME and PYTHONPATH:

  1. http://docs.python.org/using/cmdline.html#envvar-PYTHONHOME
  2. http://docs.python.org/using/cmdline.html#envvar-PYTHONPATH

and check your PYTHONHOME too.

Vladimir
  • 9,913
  • 4
  • 26
  • 37
  • 1
    links can change, and it isn't clear to a non-python user what distinction you're drawing, or how this answers the question. – bharal Aug 08 '14 at 01:49