invalid Syntax rm -rf temp (Cygwin) - python

Shell/OS: Cygwin/Windows 7
Source code: Source code
Required package: Required package
Installation:
I downloaded the following Source code on windows. I moved the requited package to models and I installed the package by using the following command: python setup.py install
Test:
by using Cygwin I wanted to test the package by typing: ./run-test:
#!/cygdrive/c/Python27/python
rm -rf temp
ocropus-nlbin tests/testpage.png -o temp
ocropus-gpageseg 'temp/????.bin.png'
ocropus-rpred -n 'temp/????/??????.bin.png'
ocropus-hocr 'temp/????.bin.png' -o temp.html
ocropus-visualize-results temp
ocropus-gtedit html temp/????/??????.bin.png -o temp-correction.html
echo "to see recognition results, type: firefox temp.html"
echo "to see correction page, type: firefox temp-correction.html"
echo "to see details on the recognition process, type: firefox temp/index.html"
Error:
File "./run-test", line 3
rm -rf temp
^
SyntaxError: invalid syntax
What caused this error?

The #! line says this is a Python script. So why would a shell command be acceptable syntactically?
Try #!/bin/sh/ instead.

Related

How do I re compile the conda, activate and deactivate commands in miniconda?

For some bizzare reason when I re-logged in to the cluster/HPC I used the conda, activate and deactivate commands stopped working. I printed the place where they'd be but they weren't there but isntead the .c~ file was there and not the bin anymore:
brando9~/miniconda/bin $ ls
2to3 certtool c_rehash genrb img2webp lzfgrep pip3.10 raw2tiff tiffcp unzstd xzegrep
2to3-3.9 chardetect cwebp gif2rgb infocmp lzgrep pip3.9 rdjpgcom tiffcrop wandb xzfgrep
activate.c cjpeg deactivate.c gif2webp infotocap lzless pkcs1-conv reset tiffdither wb xzgrep
bsdcat clear derb gifbuild jpegtran lzma pkgdata rg tiffdump webpinfo xzless
bsdcpio conda-build djpeg gifclrmp jpgicc lzmadec pkginfo sexp-conv tiffinfo webpmux xzmore
bsdtar conda.c~ dwebp giffix lame lzmainfo pngfix shortuuid tiffmedian wish zstd
bunzip2 conda-convert f2py giftext libdeflate-gunzip lzmore png-fix-itxt sqlite3 tiffset wish8.6 zstdcat
bzcat conda-debug f2py3 giftool libdeflate-gzip makeconv ppm2tiff sqlite3_analyzer tiffsplit wrjpgcom zstdgrep
bzcmp conda-develop f2py3.9 gnutls-cli libpng16-config ncursesw6-config psicc srptool tificc x86_64-conda_cos7-linux-gnu-ld zstdless
bzdiff conda-env.c~ fax2ps gnutls-cli-debug libpng-config nettle-hash psktool tabs toe x86_64-conda-linux-gnu-ld zstdmt
bzegrep conda-index fax2tiff gnutls-serv linkicc nettle-lfib-stream pydoc tclsh torchrun xml2-config
bzfgrep conda-inspect ffmpeg h264dec lz4 nettle-pbkdf2 pydoc3 tclsh8.6 tput xmlcatalog
bzgrep conda-metapackage ffprobe h264enc lz4c normalizer pydoc3.9 tic tqdm xmllint
bzip2 conda-render freetype-config iconv lz4cat ocsptool python tiff2bw transicc xz
bzip2recover conda-skeleton genbrk icu-config lzcat openssl python3 tiff2pdf tset xzcat
bzless convert-caffe2-to-onnx gencfu icuinfo lzcmp pal2rgb python3.9 tiff2ps unlz4 xzcmp
bzmore convert-onnx-to-caffe2 gencnval idle3 lzdiff patch python3.9-config tiff2rgba unlzma xzdec
captoinfo cph gendict idle3.9 lzegrep patchelf python3-config tiffcmp unxz xzdiff
I tried renaming the file to remove the tilde ~ and recompiling it with gcc -Wall activate.c -o activate for each of the three c files but it failed with this msg:
brando9~/miniconda/bin $ gcc -Wall activate.c -o activate
activate.c:1:2: error: invalid preprocessing directive #!
#!/bin/sh
^
activate.c:2:1: warning: data definition has no type or storage class
_CONDA_ROOT="/dfs/scratch0/brando9/miniconda"
^
activate.c:2:1: warning: type defaults to ‘int’ in declaration of ‘_CONDA_ROOT’ [-Wimplicit-int]
activate.c:3:3: error: invalid preprocessing directive #Copyright
# Copyright (C) 2012 Anaconda, Inc
^
activate.c:4:3: error: invalid preprocessing directive #SPDX
# SPDX-License-Identifier: BSD-3-Clause
^
activate.c:5:1: error: stray ‘\’ in program
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
^
activate.c:5:4: error: expected identifier before string constant
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
^
I tried catting the install .sh file I used with wget wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh but the output was unreadable:
...
m�gI���w%��.{=[��M7O�<��R��yj#���#K��r�q�m���V)=��O���?�˳�����MU���i2|I%�D�h�E:���/C� �l>��pD�Y����w��i#��X�eT��eҠ����Grq����X*9l���dW
�~����q�NyF?�_EbE��׳B&���>�Kw5nZ!~ʒ6m�ˡ�����ǟ�� �nX�г]1��R���S 3�}��<Z���En%'��tS�}�;�G7sFi�[��N3�W34<>[�h����M~�1�T�� {&��>H:�Eo �~��Pp�*��%�Օ� �d��H�W��H�7����~h�2�V[Iў��5O�H&�\�u�
u�ZD��Y[d�
��s*�%�u�j� y\AB����� ��qnm/5��j#k����<Z�s3�y*�i����NO�4&��~�邲�W�S��גDY��{�G���8�[���H�?��������H�e+ix�16-�yYI�܉{�j2��P�D�����ڬ��k^��=M��+ɓ�_p�!����k+!�U���B[nj�]nL�
�/5�5X&��0*:�{�=SJ\I�Z}�;?�d��6�[/�JOn'��G����X���5J���K�P��6>e�!����`*�޿��ěX2ؓ�3��h!�#�qП�R}P�1�ï�)=�U¶#|�G�^C
at which point I decided I had no idea what happened or what to fix it. Of course my path is fine as other question on SO suggest to fix Conda command not found. At this point I decided I have no idea what happened or how to fix it anymore. Any help that doesn't require an hour long re-install of conda?
related:
cross https://www.reddit.com/r/learnmachinelearning/comments/yrt9yf/how_do_i_re_compile_the_conda_activate_and/
other post that didn't help How to run Conda?
google groups: https://groups.google.com/a/anaconda.com/g/anaconda/c/DpdjFjlj0wg
quora: https://www.quora.com/unanswered/How-do-I-re-compile-the-conda-activate-and-deactivate-commands-in-miniconda
conda gitissue: https://github.com/conda/conda/issues/12086
The bin/activate and bin/deactivate files have never been binaries, but rather simple shell scripts. The situation described seems to indicate somehow a .c was appended to the file names. Looks like you could simply rename them (remove the .c) and they would go back to normal functionality.
For reference, here is my version:
$ cat ${CONDA_PREFIX}/bin/activate
#!/bin/sh
_CONDA_ROOT="/Users/mfansler/mambaforge-arm64"
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
conda activate "$#"
which essentially looks identical (up to paths), to what gcc emits in OP as the lines of the activate.c file.
However, I'd note that using bin/activate is outmoded, AFAIK. Since Conda v4.6, conda (de|)activate have been shell functions defined by conda shell.posix hook. The code in the bin/activate file is a recapitulation of what is already provided in the user shell after running conda init once (usually at installation time).

Unable to create process using '/usr/bin/env

I am trying to use Pidcat for logging. I downloaded the Pidcat.py and pasted it in the following directory:
C:\Python\Scripts
Added this path in the Environment Variables as well. But when I try to log in using the following command:
pidcat -s deviceId
I get the following error:
Unable to create process using '/usr/bin/env -S python -u "C:\Python\Scripts\pidcat.py" -s deviceId'
I used CMD to run a python file getofflinelog.py.
The command is:
python getofflinelog.py -m txt -d camlog -o offline.log
I got a similar error Unable to create process using '/usr/bin/env...., and I solved it by changing the command to:
C:\Users\liutongjun\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe getofflinelog.py -m txt -d camlog -o offline.log
I also found that if I added this path to the environment variables, the first short command would work.
I'm not very clear why it works, I do not install Python in this path and there are only a series of exe programs in this folder. Just for reference.

Unable to symlink '/usr/bin/python3' to '/home/ubuntu/my-env/bin/python3'

I have Django application which is getting deployed on Code Deploy.
In logs i get an error saying 'Unable to symlink '/usr/bin/python3' to '/home/ubuntu/my-env/bin/python3'
Any clues anyone, how to fix this issue,,..?
According to your description, I guess you used the ln -s command in Linux. And you want to link /home/ubuntu/my-env/bin/python3 to /usr/bin/python3.
When we use ln -s command, we should check if 2rd arg(/usr/bin/python3) exists.
So, I think the /usr/bin/python3 file in your system exists aready. You should delete it and attempt to redeploy.
# 1. enter /usr/bin
cd /usr/bin/
# 2. search python3 file
ls | grep python3
# 3. delete it
rm -rf python3
# 4. redeploy

"except Error as e SyntaxError" when installing nodejs

I've been trying to install nodejs on my VPS for a little while now. Since I'm using CentOs 5.6 I had to build it from source.
More so I need the python 2.7 as the default python on my box was 2.4.
I compiled python from source and it was installed successfully in /usr/local/bin/python2.7.
Now the problem is upon issuing make in the nodejs directory it reaches the following exceptions.
.
.
.
LD_LIBRARY_PATH=/root/node/out/Release/lib.host:/root/node/out/Release/lib.tar
get:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../deps/v8/tools/gyp; mkdir -p
/root/node/out/Release/obj/gen; python ../../tools/generate-trig-table.py "/root
/node/out/Release/obj/gen/trig-table.cc"
touch /root/node/out/Release/obj.host/deps/v8/tools/gyp/generate_trig_table.st
amp
LD_LIBRARY_PATH=/root/node/out/Release/lib.host:/root/node/out/Release/lib.tar
get:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../deps/v8/tools/gyp; mkdir -p
/root/node/out/Release/obj/gen; python ../../tools/js2c.py "/root/node/out/Relea
se/obj/gen/libraries.cc" CORE off ../../src/runtime.js ../../src/v8natives.js ..
/../src/array.js ../../src/string.js ../../src/uri.js ../../src/math.js ../../sr
c/messages.js ../../src/apinatives.js ../../src/debug-debugger.js ../../src/mirr
or-debugger.js ../../src/liveedit-debugger.js ../../src/date.js ../../src/json.j
s ../../src/regexp.js ../../src/arraybuffer.js ../../src/typedarray.js ../../src
/weak_collection.js ../../src/promise.js ../../src/object-observe.js ../../src/m
acros.py
File "../../tools/js2c.py", line 387
except Error as e:
^
SyntaxError: invalid syntax
make[1]: *** [/root/node/out/Release/obj/gen/libraries.cc] Error 1
make[1]: Leaving directory `/root/node/out'
make: *** [node] Error 2
Somewhere I read that the Exception syntax has changed from python 2.6 up and I figured it must be using the old python so I did the following but it made no difference:
PYTHON=/usr/local/bin/python2.7
export PYTHON
python2.7 configure && make && make install
Now I'm wondering how should I proceed?
IMO you need to place python2.7 first in path and then run:
export PATH=/usr/local/bin:${PATH}
python2.7 configure && make && make install
If this does not work, probably one of the Python scripts is looking for python. You can probably fix that by symlinking python, something like:
mkdir /tmp/py27
ln -s /usr/local/bin/python2.7 /tmp/py27/python
export PATH=/tmp/py27:${PATH}
python configure && make && make install
Is all caps PYTHON a valid environment variable?
http://www.wellho.net/resources/ex.php4?item=y115/penv.py
I would think you would rather create a sym link to the correct python interpreter.
ln -s /usr/local/bin/python2.7 /usr/local/bin/python

How to correct a compile/build issue with quickfix (v1.13.3) with Python support (... "_quickfix" import exception)

It took the equivalent of a 1/2 day for me to figure this out, so I want to share the Quickfix Engine compile problem I encountered and the solution.
I didn't get a reply from the "Quickfix Engine" help resources pointed to here:
"http://quickfixengine.org/help"... thus another reason I am providing this.
Environment: Fedora 18 -and- CentOS6 (64bit).
After successfully compiling quickfix with Python support (i.e. configure [opts]; make; make install), I got the following python import exception indicating that the python module, "_quickfix", could not be found:
==============================================
user$ python -c "import quickfix"
Traceback (most recent call last):
File " ", line 1, in
File "/home/user/APPS.d/ENTHOUGHT-PYTHON-IDE.d/x86_64.d/latest/lib/python2.7/site-packages/quickfix.py", line 7, in
import _quickfix
ImportError: No module named _quickfix
==============================================
The problem appears to be in the install script invoked by "make install".
The python interpreter is saying that the "_quickfix" module does not exit. As can be seen from the list of files install by "make install" below, there is no "_quickfix.py" file, but there is a reference to a "_quickfix.so" file and a "_quickfix.dylib" file:
/home/user/.local/lib/python2.7/site-packages/_quickfix.dylib -> /home/user/APPS.d/QUICKFIX.d/latest/lib/python/_quickfix.dylib
/home/user/.local/lib/python2.7/site-packages/_quickfix.so -> /home/user/APPS.d/QUICKFIX.d/latest/lib/python/_quickfix.so
/home/user/.local/lib/python2.7/site-packages/quickfix40.py
/home/user/.local/lib/python2.7/site-packages/quickfix41.py
/home/user/.local/lib/python2.7/site-packages/quickfix42.py
/home/user/.local/lib/python2.7/site-packages/quickfix42.pyc
/home/user/.local/lib/python2.7/site-packages/quickfix43.py
/home/user/.local/lib/python2.7/site-packages/quickfix44.py
/home/user/.local/lib/python2.7/site-packages/quickfix50.py
/home/user/.local/lib/python2.7/site-packages/quickfix50sp1.py
/home/user/.local/lib/python2.7/site-packages/quickfix50sp2.py
/home/user/.local/lib/python2.7/site-packages/quickfix.py
/home/user/.local/lib/python2.7/site-packages/quickfix.pyc
/home/user/.local/lib/python2.7/site-packages/quickfixt11.py
/home/user/APPS.d/QUICKFIX.d/latest/lib/libquickfix.la
/home/user/APPS.d/QUICKFIX.d/latest/lib/libquickfix_python.la
/home/user/APPS.d/QUICKFIX.d/latest/lib/libquickfix_python.so.10.0.0
/home/user/APPS.d/QUICKFIX.d/latest/lib/libquickfix_python.so.10 -> libquickfix_python.so.10.0.0
/home/user/APPS.d/QUICKFIX.d/latest/lib/libquickfix_python.so -> libquickfix_python.so.10.0.0
/home/user/APPS.d/QUICKFIX.d/latest/lib/libquickfix.so.14.0.0
/home/user/APPS.d/QUICKFIX.d/latest/lib/libquickfix.so.14 -> libquickfix.so.14.0.0
/home/user/APPS.d/QUICKFIX.d/latest/lib/libquickfix.so -> libquickfix.so.14.0.0
/home/user/APPS.d/QUICKFIX.d/latest/lib/pkgconfig/quickfix.pc
SOLUTION:
The problem is that the first two entries above, which are symbolic links, are broken.
First, the destination directory is incorrect:
/home/user/APPS.d/QUICKFIX.d/latest/lib/python/...
should actually be:
/home/user/APPS.d/QUICKFIX.d/latest/lib/...
So we fix that first:
user$ cd /home/user/.local/lib/python2.7/site-packages
user$ rm _quickfix.so _quickfix.dylib
user$ ln -s /home/user/APPS.d/QUICKFIX.d/latest/lib/_quickfix.so _quickfix.so
user$ ln -s /home/user/APPS.d/QUICKFIX.d/latest/lib/_quickfix.dylib _quickfix.dylib
Next, with destination directory location corrected, the symbolic links are still broken; this time because the file names that they point to in that (just corrected) destination directory don't exist (i.e. "_quickfix.so" and "_quickfix.dylib" don't exist).
After playing around a little, I got things to work by creating those missing files like so:
user$ cd /home/user/APPS.d/QUICKFIX.d/latest/lib
user$ ln -s libquickfix_python.so _quickfix.so
user$ ln -s <???> _quickfix.dylib # Actually I didn't create this one yet. It's not yet clear to me what it should point to. I Will update this post later.
-
Note: Because I compiled QuickFix so that it does not install to the traditional "/usr/local/" directory structure, I had to append my "LD_LIBRARY_PATH" to include: "/home/user/APPS.d/QUICKFIX.d/latest/lib"
With minimal testing, things seem to work now (or at least in the right direction):
user$ python -c "import quickfix"; echo ${?}
0
user$ python -c "import quickfix42"; echo ${?}
0
When I figure out what the second link should be (if it is necessary), or if I should encounter any run-time errors with the corrections I implemented, I'll update/edit this post.
I hope this helps someone.
Noel
Had the same problem in Ubuntu 13.04. configured with python support and used the default destination (/usr/local/...). After successful compilation then worked out a similar solution with the following steps;
Create missing files/symlinks;
cd /usr/local/lib
sudo ln -s libquickfix_python.so _quickfix.so
sudo ln -s _quickfix.so _quickfix.dylib
Change/update existing symlinks to new location:
cd /usr/lib/python2.7/dist-packages/
sudo ln -s /usr/local/lib/_quickfix.so _quickfix.so
sudo ln -s /usr/local/lib/_quickfix.so _quickfix.dylib
Add new library path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}/usr/local/lib
You do not need to create multiple symlinks - you only need to remove the bad symlinks and create one new symlink for _quickfix.so for everything to work:
rm /usr/local/lib/python2.7/site-packages/_quickfix.dylib
rm /usr/local/lib/python2.7/site-packages/_quickfix.so
ln -s /usr/local/lib/libquickfix_python.dylib /usr/local/lib/python2.7/site-packages/_quickfix.so
This is on OS X. For Linux you will need to use the following (as the dylib extension is OS X specific)
ln -s /usr/local/lib/libquickfix_python.so /usr/local/lib/python2.7/site-packages/_quickfix.so

Categories

Resources