I am following this tutorial to Installing OpenCv on my Raspberry Pi.
However, when I get to the stage to install the virtual environment the following commands execute without issue:
cd $cwd
python3 -m venv OpenCV-"$cvVersion"-py3
echo "# Virtual Environment Wrapper" >> ~/.bashrc
echo "alias workoncv-$cvVersion=\"source $cwd/OpenCV-$cvVersion-py3/bin/activate\"" >> ~/.bashrc
However, the last command on that list source "$cwd"/OpenCV-"$cvVersion"-py3/bin/activate throws an error bash: /OpenCV-master-py3/bin/activate: No such file or directory
I've tried using sudo before the command along with repeating the entire process with sudo-s. When I check the file path the full file is located there with instructions at the top
#This file must be used with "source bin/activate" from bash
#you cannot run it directly
I've tried skipping that step and moving onto the next one but then I get another error: sed: can't read /etc/dphy: No such file or directory - but that's a whole different question.
How can I get the terminal to find the file that I can?
Related
I attempted to follow the instructions from this link https://prishitakapoor2.medium.com/configuring-git-bash-to-run-python-for-windows-a624aa4ae2c5 to setup python with git bash. However when I attempt to run source .bashrc I receive the following error
bash: export: python.exe export PATH=/mingw64/bin:/usr/bin:/c/Users/Grant/bin:/c/Program Files/Oculus/Support/oculus-runtime:/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler:/c/ProgramData/Oracle/Java/javapath:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/Program Files (x86)/AMD/ATI.ACE/Core-Static:/c/Program Files (x86)/Calibre2:/c/Program Files (x86)/QuickTime/QTSystem:/c/WINDOWS/System32/OpenSSH:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/dotnet:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files/Azure Data Studio/bin:/cmd:/c/Udacity/Python:/c/Udacity/Python/Library/mingw-w64/bin:/c/Udacity/Python/Library/usr/bin:/c/Udacity/Python/Library/bin:/c/Udacity/Python/Scripts:/c/Users/Grant/AppData/Local/Microsoft/WindowsApps:/c/Program Files/Azure Data Studio/bin:/c/Users/Grant/AppData/Local/atom/bin:/c/Users/Grant/Anaconda3:/c/Users/Grant/Anaconda3/scripts alias python=winpty:/c/users/grant/anaconda3:/c/users/grant/anaconda3/Scripts:\C\Users\Grant\anaconda3:\C\Users\Grant\anaconda3/Scripts:\C\Users\Grant\Desktop\anaconda3:\C\Users\Grant\Desktop\anaconda3\Scripts:/c/Users/Grant/Anaconda3:/c/Users/Grant/Anaconda3/scripts': not a valid identifier bash: .bashrc: line 13: unexpected EOF while looking for matching "'
I have attempted to uninstall both batch and anaconda and reinstall both to fix the issue but I am unable to resolve the problem. Any tips? I am very new to this and trying to get python setup on my local PC for the first time.
I attempted to update the path by using the echo 'export PATH="$PATH:[YOUR_PATH]:[YOUR_PATH]/Scripts"' >> .bashrc again but this did not allow me to change the path and I am still receiving the same error.
As error tells, you have unmatched " in your .bashrc file. To more accurate answer,will be good if you attach .bashrc file
how would I run python script on startup (on Raspberrypi 4B, Raspi_os 64bit) within an python(3.9) environment?
I tried to just add
source envname/bin/activate to launcher.sh
my launcher file looks like this:
cd /home/pi/thefolder
PYTHONPATH=/home/pi/.local/lib/python3.9/site-package
source envname/bin/activate
pyhton3 /home/pi/thefolder/run.py
Apparently the python3 command is not run in the env as I get an ModuleNotFoundError for Pandas. Which is installed in the env.
EDIT1:
if I just create a new shell script with only
source envname/bin/activate
echo Hi Stackoverflow
running after chmod with sh test.sh I get the return
> test.sh 1: source: not found
> Hi Stackoverflow
while I can activate the env in the terminal
EDIT2:
Apparently Ubuntu bin/dash ist used and not bin/sh. Here is post about it
Now I have to checkout how to change it
Edit3:
using :
. envname/bin/activate
echo Hi Stackoverflow
instead of
source envname/bin/activate
echo Hi Stackoverflow
seems to work. Testing in progress
---Final Edit:---
Yes it works. But important, it apparently has to be in the first line otherwise the file envname cannot be found
Using
. envname/bin/activate
echo Hi Stackoverflow
instead of
source envname/bin/activate
echo Hi Stackoverflow
Works. As Ubuntu uses /bin/bash instead of /bin/sh
Apparently the . envname/bin/activate has to be the first command
I've created a pipenv environment and now I'm creating a shell script called bootstrap.sh to activate it and run a flask server, but the following line is producing an error
bootstrap.sh reads as follows
#!/bin/sh
...
source "$(pipenv --venv)\\Scripts\\activate"
...
Running simply pipenv --venv returns C:\Users\johng\.virtualenvs\cashman-flask-project-2vwc8e6G
But executing the shell script returns a No such file or directory error
$ source bootstrap.sh
/Scripts/activate: No such file or directoryask-project-2vwc8e6G
This is in the vsCode bash terminal on Windows 10. The file certainly exists and can be navigated to, so what is causing this?
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.
I trying to setup virtualenvwrapper in GitBash (Windows 7). I write the next lines:
1 $ export WORKON_HOME=$HOME/.virtualenvs
2 $ export MSYS_HOME=/c/msys/1.0
3 $ source /usr/local/bin/virtualenvwrapper.sh
And the last line give me an error:
source /usr/local/bin/virtualenvwrapper.sh
sh.exe: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
I find, where on my drive is virtualenvwrapper.sh and change directory name. On my computer it's /c/Python27/Scripts/virtualenvwrapper.sh. When I again run command
$source /c/Python27/Scripts/virtualenvwrapper.sh
I get the next ERROR message:
sh.exe":mktemp:command not found ERROR: virtualenvwrapper could not create a temporary file name
I check my enviroment variable: C:\python27\;C:\python27\scripts\;C:\python27\scripts\virtualenvwrapper.sh\;C:\msys;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin\
I don't know where i made a mistake
The error is saying that sh.exe (the shell) can't find a command matching mktemp, which means it's not present in GitBash, at least not in your environment.
One option is you could download a Windows version of mktemp, such as http://gnuwin32.sourceforge.net/packages/mktemp.htm and then place it in the C:\Program Files (x86)\Git\bin directory. The shell should then be able to match the mktemp command and be able to proceed.
I've found a fix for this problem on a Windows 8 machine using GitBash.
TL;DR:
Get mktemp for windows, put it somewhere that can be used by GitBash, then edit virtualenvwrapper.sh and on line 202, add a touch command with the file created. It should look like this:
file="$(virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)"
touch $file # this is the new line
if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ]
FULL ANSWER:
As khampson mentioned, you do have to download mktemp and place it where your Git\bin (C:\Program Files (x86)\Git\bin usually) directory is. After that, running the virtualenvwrapper.sh file would cause an error saying:
path = C:/Users/User/AppData/Local/Temp/virtualenvwrapper-initialize-hook-XXXXXX XXXX
lpPathBuffer = C:\Users\User\AppData\Local\Temp\
szTempName = C:\Users\User\AppData\Local\Temp\tmp23A9.tmp
path = C:\Users\User\AppData\Local\Temp\tmp23A9.tmp
fd = 3
ERROR: virtualenvwrapper could not create a temporary file name.
On line 202(source), you see a function call to virtualenvwrapper_mktemp (which is just a wrapper function to call mktemp) and this is supposed to create the new temp file, but apparently it doesn't on windows.
Going through the manual for mktemp, on the examples section, you see that they are always sending something to that new file handle which forces the file to be created.
So instead of sending an empty string using echo like the manual, just add a touch command to the virtualenvwrapper.sh:
file="$(virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)"
touch $file # new command here
This should force windows to create the temp file. I can't post the rest of the links due to low rep but I hope this still helps someone.
EDIT
I created a pull request on the virtualenvwrapper repo and it got approved. You can see the touch command I suggested added here.