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.

Regarding TESSDATA_PREFIX environment variable, it seems that new directory has to be parent directory of original tessdata folder. However, /usr/share/ directories are blocked from writing ("permission denied"). So how to insert lang.traineddata into parent directory?

That sounds odd -- where did you get the information about it needing to be a parent directory?

I'm stuck on the issue regarding language packages for pytesseract!

What I understood, if I:

  1. upload swe.traineddata to "/home/myuser/"
  2. set up an environment variable with following python code: import os os.environ["TESSDATA_PREFIX"] = "/home/myuser/"

Then pytesseract should work for Swedish in my case? What am i missing?

Thankful for help! //D

I'm stuck on the issue regarding language packages for pytesseract!

What I understood, if I:

  1. upload swe.traineddata to "/home/myuser/"
  2. set up an environment variable with following python code: import os os.environ["TESSDATA_PREFIX"] = "/home/myuser/"

Then pytesseract should work for Swedish in my case? What am i missing?

Thankful for help! //D

EDIT: NVM! I got it to work! two more steps were needed:

  1. make sure place the traineddata in a folder called tessdata, e.g. "/home/myuser/tessdata/", the prefix should however only be "/home/myuser/"

  2. Make sure you have the right version of traineddata! I initially used version 4, but pythonanywhere version is 3.04!

ah great! thanks for figuring it out and letting everyone else know!

How can I use the sudo command Please Help me

sudo is not available on PythonAnywhere.

I want to install RabitMQ server which is installed through sudo apt-get. Can you please suggest me how can I install that?

You can't install it and even if you could, at the moment, it would be very unlikely that you would be able to use it effectively on PythonAnywhere.

Hi, I need to use Timidity on pythonanywhere but I don't know how to install. Anyone could help me? Thank you in advance.

I don'tz know what that is. Please send a link to install documentation.

Hi again, this is the link:

http://timidity.sourceforge.net/install.html

Thankyou!

Hi again, this is the link:

http://timidity.sourceforge.net/install.html

Thankyou!

That should work if you follow the "The simplest way" instructions there, with one tweak -- when you run "./configure" you'll need to pass in a flag to tell it to install it into your home directory, like this:

./configure --prefix=~/.local

hi, how can I install redis-server in PythonAnywhere since sudo apt-get install redis-server can't work?

There's no good way to run redis inside PythonAnywhere right now, unfortunately. With a paid account you can use third-party redis providers like Redis Labs.

Hey I am getting this while trying to install textract:

include <pulse/pulseaudio.h>

                              ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I assume I need to do something like this:

sudo apt-get install python-dev any suggestions?

We already have python-dev installed. The problem is that you're trying to use the pulseaudio library that is not installed because our servers have no sound hardware.

HI there... Can we use pynput or python keyboard library for key press simulation???

No, I don't think that would work -- pynput and the like are designed to affect the keyboard (or mouse) on the computer where the code is running. On PythonAnywhere, your code is running on our servers, so there is no keyboard attached -- you just have a remote login to the server over the network.

https://github.com/tesseract-ocr/tesseract Latest is 4.1.0

But on pythonanywhere.com version 3.04.01 is installed.

>>> import pytesseract
>>> pytesseract.get_tesseract_version()
LooseVersion ('3.04.01')

Can we have the latest version because this version is performing poorly.

You can upgrade pre-installed packages using pip without needing sudo -- see this help page for details.

Thanks for reply. I discovered recently how to upgrade packages via bash. pytesseract is only a wrapper, real tesseract-ocr is installed via apt install ...

sudo apt install tesseract-ocr 
sudo apt install libtesseract-dev

This is something only YOU can do.

However on my Ubuntu 18.04 system, latest version says it's:

>>> import pytesseract
>>> pytesseract.get_tesseract_version()
LooseVersion ('4.0.0-beta.1')

duplicate

Ah, I see. Yes, it looks like the version of the underlying Tesseract library that we have is 3.04.00 -- the default for our OS version, as we're on Ubuntu 16.04. Unfortunately upgrading that is still some time in the future -- we don't have an ETA right now.

pytesseract.tesseract_cmd = 'C:\Program Files\Tesseract-OCR\tesseract.exe'

what can we use instead of this path as we are hosting our website on linux....can any help

You can use

which tesseract

in a Bash console to find the path to tesseract (and any other executable that you need to find)

will someone tell me how to install tesseract-ocr in your bash

It is already installed and at some point in the future, we will update to a more recent version. If you need a more recent version now, and you have the technical knowledge, you can try compiling from source yourself and installing the result in your home directory. There should be instructions on how to do that in the tesseract-ocr documentation.

Hello, is it possible to add neofetch, or some other analogue for a beautiful display of information about a virtual machine?

Sure -- I've added it as a suggestion for our next system image.

UPDATE: neofetch has been installed to our new system image, "haggis", see this blog post for more information.