Can't run GitHub file through CMD on windows - python

I'm trying to run a run a file from a GitHub repo using the Command Prompt on Windows. I started with these commands:
python -m pip install virtualenv
python -m virtualenv ocopus_venv
.\venv\Scripts\activate.bat
curl -O https://github.com/zuphilip/ocropy-models/raw/master/en-default.pyrnn.gz
move en-default.pyrnn.gz models
No errors so far, but when I run:
./ocropus-nlbin tests/ersch.png -o book
I got this error: the '.' is not recognized
How can I make this command run properly?

On Windows cmd this doesn't work. Try without the ./ at the beggining. Condering ocropy supports Windows you can run it also wtih python2.7.
python ocropus-nlbin tests/ersch.png -o book
Don't forget you have to run python setup.py install before.

Related

Bad python path in bash script from crontab

I would like to use the python3 executable when I use it from crontab as manual launch (ssh session).
bash script
#!/bin/bash
PYTHONPATH="$(which python3)"
echo $PYTHONPATH
python3 test.py
result from ssh command line, launched manually
/usr/local/bin/python3
result in log file from crontab -e
/usr/bin/python3
I would like the script launched by the crontab, uses /usr/local/bin/python3 executable instead of /usr/bin/python3
OR
if it's not possible, use the dependencies of my code available for /usr/bin/python3
How can I achieve this ? Thank you very much for your help
the python inside the docker container will not necessarily have the same path. If you want all the modules installed on your VM python3, create a requirements.txt file using pip freeze > requirements.txe and COPY this file as part of your Dockerfile and install it while building the image pip install -r requirements.txt

Python - Running an pip installed package from cli

I just came across a pip package I want to use however I'm new to python and PIP and not sure - is it possible to run that directly from terminal/the command line. If so, I can't seem to find the syntac to run a pip package.
So I installed pip using:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
then
python get-pip.py
I then checked installation, by the command python -m pip
I then installed the package like:
python -m pip install openapi-cli-tool
Anyhow, as per the docs of that package I though I could just do:
openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html
Which didn't work, neither did this:
python -p pip openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html
Any help in explaining how this works would be appreciated.
You have to install it with pip, run command below:
pip install openapi-cli-tool
Then openapi-cli-tool will be available in your terminal, so you shall be able to run command, the command below is with correction of parameters passing:
Make sure you have file1.json and file2.yaml in file system.
openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html
python -m pip install
Installs the package to the user's local directory (iirc)
So, you can access it from ~/.local/bin/, like this:
~/.local/bin/openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html
You can add ~/.local/bin to your path by
export PATH=$PATH:$HOME/.local/bin
and probably add that line to your .bashrc or it's equivalent.
Then, you can access it by just openapi-cli-tool bundle

Add Miniconda binaries to path in Docker container

I'm using the following commands in my Dockerfile to install Miniconda. After I install it, I want to use the binaries in ~/miniconda3/bin like python and conda. I tried exporting the PATH with this new path prepended to it, but the subsequent pip command fails (pip is located in ~/miniconda3/bin.
Curiously, if I run the container in interactive terminal mode, the path is set correctly and I'm able to call the binaries as expected. It seems as though the issue is only when building the container itself.
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install -y python3.7
RUN apt-get install -y curl
RUN curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh --output miniconda.sh
RUN bash miniconda.sh -b
RUN export PATH="~/miniconda3/bin:$PATH"
RUN pip install pydub # errors out when building
Here's the result of echo $PATH
~/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Here's the error I get
/bin/sh: 1: pip: not found
export won't work. Try ENV
Replace
RUN export PATH="~/miniconda3/bin:$PATH"
with
ENV PATH="~/miniconda3/bin:$PATH"
Even though Miniconda is located in ~, it default installs to the root directory unless otherwise specified.
Here's the right command.
RUN export PATH="/root/miniconda3/bin:$PATH"
It looks like your export PATH ... command is putting the literal symbol ~ into the path. Try this:
ENV PATH="$HOME/miniconda3/bin:$PATH"

AWS Elastic Beanstalk (eb) installation in Ubuntu 14.04: command not found

Im trying to install AWS eb command line interface in Ubuntu 14.04. I just donwloaded the .zip file. Extracted in a folder. if I go to folder where eb is (/home/roberto/app/AWS-ElasticBeanstalk-CLI-2.6.1/eb/linux/python2.7) and run it, I get: eb: command not found
Same if I do it with python3 path.
Fixed:
I just ran the command on a terminal:
$ export PATH=$PATH:/opt/aws/eb/linux/python2.7/
and it's working.
I think all you have to do is, upgrade awsebcli by running: pip install --upgrade awsebcli
If you are using arch linux:
Find your shell's profile script, in case of bash use .bash_profile
run
$ ls -a ~
$ nano profile_script` #in my case `$ nano .bash_profile
Add
export PATH=~/.local/bin:$PATH
Save and exit.
Now run
$source ~/profile_script
In ubuntu we write like :
export PATH=$PATH:/usr/local/lib/python2.7/site-packages/
It worked for me after writing this because eb folder will be present inside mentioned folder.

Cannot run Hello World Open

I am competing in the HWO2014, yet I cannot run my bot. Here is the build file I was provided with, alongside the run file:
build:
#!/bin/bash
virtualenv env --no-site-packages --distribute
source env/bin/activate
run:
#!/bin/bash
source env/bin/activate
python main.py "$#"
However, when I run ./build on the MinGW terminal, the following error is reported:
./build: line 3: virtualenv: command not found
./build: line 5: env/bin/activate: No such file or directory
What does this error mean? How do I prevent it?
You need to install virtualenv on your machine. The run file is a bash script which is saying to go into the newly created virtual environment before running the python script. More info can be found on the official virtualenv docs.

Categories

Resources