ptpb / pb

pb is a formerly-lightweight pastebin and url shortener
Other
549 stars 52 forks source link

Ubuntu Installation #201

Closed fStiedemann closed 6 years ago

fStiedemann commented 6 years ago

Hey,

There are no instructions for debian/ubuntu installations. I did this:

$ sudo apt-get install mongodb uwsgi python3-pip 
$ git clone https://github.com/ptpb/pb.git
$ cd pb/
$ pip3 install -r requirements.txt
$ chmod +x setup.py
$ ./setup.py 

And get this error:

./setup.py: line 3: syntax error near unexpected token newline' ./setup.py: line 3:setuptools.setup('

How exactly do I install pb in ubuntu 16?

buhman commented 6 years ago

There are no instructions for debian/ubuntu installations.

Yeah, this could be improved.

./setup.py: line 3: syntax error near unexpected token newline' ./setup.py: line 3:setuptools.setup('

This is because setup.py contains no interpreter directive, so it's being executed by your shell instead of by python. Because you're already using pip anyway, I instead suggest:

pip3 install .

How exactly do I install pb in ubuntu 16?

After installed, if you want to use uwsgi, use a config like this:

[uwsgi]
http-socket = [::]:8080
module = pb.__main__:app
plugins = python3
ragaraga commented 6 years ago

hello i did pip3 install . and everything installed successfully. mongodb is listening, how do i start pb now? can you recommend a systemd pb.service conf?

buhman commented 6 years ago

how do i start pb now?

In my opinion, docker is the best way to do pretty much everything. The docker-compose file that pb ships with works great.

can you recommend a systemd pb.service conf?

Unrelated to what I just said, this pb.service still looks pretty valid provided you have uwsgi install on a distribution like archlinux that ships a uwsgi@.service, and have a pb.ini in the correct place.

Another alternative is to just run:

python -m pb

jowypej commented 6 years ago
$ uname -a
Linux server 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux

user@server:/var/www/pb$ python -m pb

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/var/www/pb/pb/__main__.py", line 17, in <module>
    import sys, __main__
  File "pb/__main__.py", line 31, in <module>
    from pb import db
  File "pb/pb.py", line 15, in <module>
    from pb.cache import init_cache
ImportError: No module named cache

user@server:/var/www/pb$ python3 -m pb

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/var/www/pb/pb/__main__.py", line 21, in <module>
    p = path(p).resolve()
  File "/usr/lib/python3.5/pathlib.py", line 1109, in resolve
    s = self._flavour.resolve(self)
  File "/usr/lib/python3.5/pathlib.py", line 330, in resolve
    return _resolve(base, str(path)) or sep
  File "/usr/lib/python3.5/pathlib.py", line 315, in _resolve
    target = accessor.readlink(newpath)
  File "/usr/lib/python3.5/pathlib.py", line 422, in readlink
    return os.readlink(path)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python35.zip'

user@server:/var/www/pb$ 

Any advice? How do I resolve ImportError: No module named cache?

buhman commented 6 years ago

ImportError: No module named cache

This is because python2's import mechanism by default is relative, while some of pb imports depend on python3-style absolute_import. pb overall is not compatible with python2 in other ways as well. I guess it might be helpful to do version checking in setup.py; I just never imagined someone would try this.

FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python35.zip'

It looks like your python3.5 installation is incomplete. Maybe try making sure it is completely installed with:

apt-get install python3

Also if you're using anything older than debian stretch (jessie/wheezy), that version of python3 will be too old as well.

python3.5 has a separate site-packages, so you'll need to make sure you have a working pip3 and install pb into your python3.5 site-packages as well.

buhman commented 6 years ago

IMO, working with system python installations is a massive pain. You might also try this easy 3-step docker deployment method:

1) Install docker

https://docs.docker.com/engine/installation/linux/docker-ce/debian/#install-docker-ce

2) start mongo

docker run -d --name mongodb mongo

3) start pb (latest, auto-generated from master)

docker run -d --link mongodb --publish 10002:10002 ptpb/pb

Verify with curl http://localhost:10002

jowypej commented 6 years ago

Thanks so much. The docker installation you linked to was helpful.