PythonAnywhere Forums

sudo-apt-get not working in the bash console

I need to get a ppa repository. When I type sudo it says command not found. Can any one throw light on what is happening?

Yes, sudo is not available. apt-get is not either.

Thank you for the reply. So could you suggest some solution for this?

What do you want to install, I wonder?

Jim

I need to install pythonOCC, an opensource library from ppa repository.

That's interesting, you're the second person to ask for that in the last few days. Was it recommended for a course or something?

The problem is that it needs a c++ compiler, which we don't currently support. We may be able to get it compiled for you though. I'll see if we can fit it into our next release. I'm afraid I can't guarantee it though...

Hi Harry,

Thank you for your reply. pythonOCC can also be imported as a ppa repository so that we might not require a C++ compiler. However this might require that bash console should accept sudo-apt-addrepository...

Just wanted to know if more advanced scripting options are available for paid users?

sudo is not available for anyone I'm afraid, so upgrading to a paid account won't solve this problem. I'll have a talk with my colleagues on Monday to see if there's anything we can do for you, but otherwise I'm afraid you probably won't be able to get pythonOCC installed until we're able to prepare a new system image and run it through testing.

Did this issue get resolved? We are trying to play with PYOCC on pythonanywhere

hi there,

So sudo is still restricted, but we actually have the whole gcc tool chain etc now, so you may be able to compile it- test it out and let us know!

Conrad

Dear Sir, Based on our review the application we are trying to develop requires PYOCC. It is mandatory. We need an OCC backend. I am afraid without being able to install some packages our app becomes restricted and unviable. Would it be possible to look into this and get the PYOCC into your standard libraries? Would appreciate a response. Otherwise we would need to look at other hosting platforms. Regards

We can have a look at getting that installed for you, though it's not going to be available for a few weeks.

Hi! I think that I need libsqlite3-dev for my progect. When I will be paid user, command sudo apt-get install libsqlite3-dev will be available for me... Is it rigth?

sudo doesn't work in paid accounts either, but libsqlite3-dev is already installed for all accounts -- you can confirm that by running this in a bash console:

dpkg -l | grep libsqlite3-dev

Any progress with PythonOCC , if so how does one install it on the virtual env pythonanywhere paid account. Thanks

Hi there, PythonOCC is currently still not supported I'm afraid. I will add a +1 in our tracker.

If you have some time, you could look into installing conda, and then installing python-occ through that? I can't think of any theoretical reason that would prevent it from working...

Hi Harry, thanks for the tip

Thanks for the tip Harry, I just about got PythonOCC installed by I taking the following steps

pip install auxlib

pip install conda

pip install ruamel

pip install ruamel.yaml.cmd

pip install requests

pip install pycosat

conda install -c https://conda.anaconda.org/dlr-sc pythonocc-core=0.17

I've got to a error while installing. Any ideas how to fix this ...

Linking packages ... CondaOSError: OS error: failed to link (src='/home/shimwell/.virtualenvs/myvirtualenv/pkgs/python-3.5.2-0/include/python3.5m/Python-ast.h', dst='/home/shimwell/.virtualenvs/myvirtual env/include/python3.5m/Python-ast.h', type=1, error=FileExistsError(17, 'File exists'))

Maybe that file is there from a previous failed attempt to install?

What happens if you use a new virtualenv?

I just removed my old virtualenv and made a fresh one

unfortunately I still get the error

Linking packages ... CondaOSError: OS error: failed to link (src='/home/shimwell/.virtualenvs/myvirtualenv/pkgs/python-3.5.2-0/include/python3.5m/Pytho n-ast.h', dst='/home/shimwell/.virtualenvs/myvirtualenv/include/python3.5m/Python-ast.h', type=1, error=FileExistsError(17, 'File exists'))

I've tried deleting the dst file and moving it but apparently this requires sudo privileges

I think the ast is probably symlinked to something that you can't delete. Can you double check by doing an ls -l on it? I wonder if you can make your virtualenv with the --always-copy option so that it hard copies over the files so you can then remove/overwrite it. (it's a virtualenv flag when you create it, but I think virtualenvwrapper's mkvirtualenv doesn't have that option. not entirely sure)

Many thanks Conrad, I used ls -l and it was a symlink just as you said. After using the --always-copy copy option when making the vurtualenv it all worked perfectly. Thanks very much.

Hi, Sirs, Can I install tesseract-OCR? I tried and errors like following:

13:13 ~/ulink (master)$ pip install tesseract-ocr
Collecting tesseract-ocr
  Downloading tesseract-ocr-0.0.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): cython in /usr/local/lib/python2.7/dist-packages (from tesseract-ocr)
Building wheels for collected packages: tesseract-ocr
  Running setup.py bdist_wheel for tesseract-ocr ... error
  Complete output from command /usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-6Nl2cw/tesseract-ocr/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp4IZRJepip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  file tesseract_ocr.py (for module tesseract_ocr) not found
  file tesseract_ocr.py (for module tesseract_ocr) not found
  running build_ext
  building 'tesseract_ocr' extension
  creating build
  creating build/temp.linux-x86_64-2.7
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c tesseract_ocr.cpp -o build/temp.linux-x86_64-2.7/tesseract_ocr.o
  cc1plus: warning: command line option -Wstrict-prototypes is valid for C/ObjC but not for C++ [enabled by default]
  tesseract_ocr.cpp:288:34: fatal error: leptonica/allheaders.h: No such file or directory
   #include "leptonica/allheaders.h"
                                    ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for tesseract-ocr
  Running setup.py clean for tesseract-ocr
Failed to build tesseract-ocr
Installing collected packages: tesseract-ocr
  Running setup.py install for tesseract-ocr ... error
    Complete output from command /usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-6Nl2cw/tesseract-ocr/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zndPig-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    file tesseract_ocr.py (for module tesseract_ocr) not found
    file tesseract_ocr.py (for module tesseract_ocr) not found
    running build_ext
    building 'tesseract_ocr' extension
    creating build
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c tesseract_ocr.cpp -o build/temp.linux-x86_64-2.7/tesseract_ocr.o
    cc1plus: warning: command line option -Wstrict-prototypes is valid for C/ObjC but not for C++ [enabled by default]
    tesseract_ocr.cpp:288:34: fatal error: leptonica/allheaders.h: No such file or directory
     #include "leptonica/allheaders.h"
                                      ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__f
ile__='/tmp/pip-build-6Nl2cw/tesseract-ocr/setup.py';exec(compile(getatt
r(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file
__, 'exec'))" install --record /tmp/pip-zndPig-record/install-record.txt
 --single-version-externally-managed --compile" failed with error code 1
 in /tmp/pip-build-6Nl2cw/tesseract-ocr/
13:15 ~/ulink (master)$

[edit by admin: formatting]

If you're installing pip modules you need to use the --user flag, or a virtualenv -- more about that on this help page.

However, that probably won't help with the specific error that you're seeing, which seems to relate to a system library we don't have installed. Have you considered using the pytesseract module instead? We have that already installed for you.

pytesseract works fine, thanks. But, I want to try pytesseract with Japanese, and I need to copy jpn.traineddata to /usr/share/tesseract-ocr/tessdata/.

13:49 ~/pytesseract $ cp jpn.traineddata /usr/share/tesseract-ocr/tessdata/ cp: cannot create regular file ‘/usr/share/tesseract-ocr/tessdata/jpn.traineddata’: Permission denied

Could you copy Japanese and Chinese train data?

Japanese train data: https://github.com/tesseract-ocr/tessdata/blob/master/jpn.traineddata

Chinese train data: https://github.com/tesseract-ocr/tessdata/blob/master/chi_sim.traineddata

Installing that into the standard system image isn't something we can do easily -- but it looks like you can specify where the Tesseract data lives by using the TESSDATA_PREFIX environment variable...?

"by using the TESSDATA_PREFIX environment variable"

Thanks, it worked well.

:)

Hello, I tried the solution above and added TESSDATA_PREFIX to my WSGI file, copied all the content from the tessdata folder from my pc, but got this error:

TesseractError: (1, 'Tesseract Open Source OCR Engine v3.03 with Leptonica\nread_params_file: parameter not found: hocr_font_info\n')

the tesseract installed on my pc is version 3.05.01, while on pythonanywhere it's tesseract 3.03 AFAIK. Could this be the source of the issue? If so, how do I solve this problem?

as always, thanks in advance.

can you install v 3.03 on your PC?

I have to build it from source since all the installers available are for version 3.05 upwards. I prefer the solution that doesn't need me to go backward in terms of versions if possible, since I'm wary that it might break my code, and it would need to be updated sooner or later, right?

Is it possible to install tesseract 3.05 on my environment?

Unfortunately we can't update tesseract for just one account -- it would have to be system-wide, which could break other people's stuff. You could in theory compile it yourself, keep the updated copy in your home directory, and modify LD_LIBRARY_PATH to point to it, but that's not something we can give detailed instructions for.

Could you install rethinkdb?

That would be trickier -- installing it into the system image would be reasonably easy, but getting routing to it so that it could be accessed from outside PythonAnywhere would be hard.

Compose, the company formerly known as MongoHQ, seem to provide RethinkDB as a service -- perhaps you could get an instance from them? If you ask them to put it in the AWS us-east-1 datacenter then it will be close to the PythonAnywhere systems in network terms, so you'd be able to access the DB from your Python code with minimal latency.