Google Colab - How can I get rid of "FileNotFoundError" error for a function call? - ipython

As the title clearly describes the issue, I've been getting a FileNotFoundError error for a function call on Google Colab. You may find my script below. How can I resolve this issue? Any helps will be appreciated a lot.
def main():
# some code
if __name__ == '__main__':
main()
Error message:
FileNotFoundError Traceback (most recent call last)
<ipython-input-6-e292631388d3> in <module>()
160
161 if __name__ == '__main__':
--> 162 main()
4 frames
FileNotFoundError: [Errno 2] No such file or directory: '/content/<ipython-input-6-e292631388d3>'

Related

Runing the sample code for google assistant sdk giving SyntaxErorr: invalid syntax

I'm trying to run the following code for starting my google assistant with the raspbery pi:
googlesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model
But I get the following error:
Traceback (most recent call last):
File "/home/pi/env/bin/googlesamples-assistant-pushtotalk", line 5, in <module>
from googlesamples.assistant.grpc.pushtotalk import main
File "/home/pi/env/lib/python3.9/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 29, in <module>
from tenacity import retry, stop_after_attempt, retry_if_exception
File "/home/pi/env/lib/python3.9/site-packages/tenacity/__init__.py", line 292
from tenacity.async import AsyncRetrying
^
SyntaxError: invalid syntax
Just use:
pip install -U tenacity
Solve for me...

Pyspark: SPARK_HOME may not be configured correctly

I'm trying to run pyspark using a notebook in a conda enviroment.
$ which python
inside the enviroment 'env', returns:
/Users/<username>/anaconda2/envs/env/bin/p
ython
and outside the environment:
/Users/<username>/anaconda2/bin/python
My .bashrc file has:
export PATH="/Users/<username>/anaconda2/bin:$PATH"
export JAVA_HOME=`/usr/libexec/java_home`
export SPARK_HOME=/usr/local/Cellar/apache-spark/3.1.2
export PYTHONPATH=$SPARK_HOME/libexec/python/:$PYTHONPATH
export PYTHONPATH=$SPARK_HOME/python/lib/py4j-0.10.9-src.zip:$PYTHONPATH
But still, when I run:
import findspark
findspark.init()
I'm getting the error:
Exception: Unable to find py4j, your SPARK_HOME may not be configured correctly
Any ideas?
Full traceback
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
~/anaconda2/envs/ai/lib/python3.7/site-packages/findspark.py in init(spark_home, python_path, edit_rc, edit_profile)
142 try:
--> 143 py4j = glob(os.path.join(spark_python, "lib", "py4j-*.zip"))[0]
144 except IndexError:
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
/var/folders/dx/dfb8h2h925l7vmm7y971clpw0000gn/T/ipykernel_72686/1796740182.py in <module>
1 import findspark
2
----> 3 findspark.init()
~/anaconda2/envs/ai/lib/python3.7/site-packages/findspark.py in init(spark_home, python_path, edit_rc, edit_profile)
144 except IndexError:
145 raise Exception(
--> 146 "Unable to find py4j, your SPARK_HOME may not be configured correctly"
147 )
148 sys.path[:0] = [spark_python, py4j]
Exception: Unable to find py4j, your SPARK_HOME may not be configured correctly
EDIT:
If I run the following in the notebook:
import pyspark
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
I get the error:
/usr/local/Cellar/apache-spark/3.1.2/bin/load-spark-env.sh: line 2: /usr/local/Cellar/apache-spark/3.1.2/libexec/bin/load-spark-env.sh: Permission denied
/usr/local/Cellar/apache-spark/3.1.2/bin/load-spark-env.sh: line 2: exec: /usr/local/Cellar/apache-spark/3.1.2/libexec/bin/load-spark-env.sh: cannot execute: Undefined error: 0

Error encountered when using Autodock/Vina Plugin in PyMOL

I am a beginner to PyMOL and I am using it for my docking project. I have encountered errors using the Autodock/Vina plugin in PyMOL.
I was trying to carry out the set up for the grid and Error 1 occurred when I was clicking on the arrow that allows me to change the grid parameter x,y and z.
As for Error 2, it occurs when I tried to generate the receptor on the next page.
Under the log section, I also got a notice saying "Batch: prepare_receptor4.py -r C:\Users\User\Desktop\plugin-test\receptor.3ig7.pdb -o C:\Users\User\Desktop\plugin-test\receptor.3ig7.pdbqt -A checkhydrogen"
It would be appreciated if you would tell me what is missing or should be done to solve these errors.
I look forward to reading any of your replies and I thank you in advance,
Elayne
Error: 1
TypeError Exception in Tk callback
Function: <bound method Autodock.n_points_Y_changed of <pmg_tk.startup.autodock_plugin.Autodock object at 0x0000020649CD9388>> (type: <class 'method'>)
Args: ('scroll', '1', 'units')
Traceback (innermost last):
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\Pmw.py", line 1823, in __call__
return self.func(*args)
TypeError: n_points_Y_changed() takes 2 positional arguments but 4 were given
Error: 2
FileNotFoundError Exception in Tk callback
Function: <bound method Autodock.generate_receptor of <pmg_tk.startup.autodock_plugin.Autodock object at 0x0000020649CD9388>> (type: <class 'method'>)
Args: ()
Traceback (innermost last):
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\Pmw.py", line 1823, in __call__
return self.func(*args)
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\pmg_tk\startup\autodock_plugin.py", line 1940, in generate_receptor
result, output = getstatusoutput(command)
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\pmg_tk\startup\autodock_plugin.py", line 85, in getstatusoutput
p = Popen(args, stdout=PIPE, stderr=STDOUT, stdin=PIPE, env=env)
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I'm also encountering the same issue on Windows, try running a linux distro on vmware and make sure to install Pymol with support for Python 2.7 because the script is not compatible with Python3.

SyntaxError: invalid syntax EngineerIO.py", line 133 running simulation on IBM Cloud

Works locally on mac. Gives syntax error below running on IBM Cloud using:
python-3.5.6
Requirements.txt
Flask==0.10.1
requests==2.12.4
flask-restful-swagger==0.19
flask-restplus==0.9.2
watson-developer-cloud>=1.3.5
python-dotenv==0.8.2
cloudant==2.12.0
UliEngineering==0.3.3
scipy>=0.5
toolz==0.10.0
numpy>=1.5
Error
Traceback (most recent call last): File "skill.py", line 16, in <module> from UliEngineering.SignalProcessing.Simulation import sine_wave File "/home/vcap/deps/0/python/lib/python3.5/site-packages/UliEngineering/SignalProcessing/Simulation.py", line 8, in <module> from UliEngineering.EngineerIO import normalize_numeric File "/home/vcap/deps/0/python/lib/python3.5/site-packages/UliEngineering/EngineerIO.py", line 133 self.unit_prefix_re = re.compile(f'({__unitprefix_set})+$') # $: Matched at end of numeric part ^ SyntaxError: invalid syntax
Any ideas how I might be able to fix this?

IOError error message in IPython notebook when using StarCluster

I am running a small StarCluster and using it to run an IPython Notebook. Every time I have an error in the code I'm writing in the notebook, I get the following error message added onto the end of the notebook's output:
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 872, in emit
stream.write(fs % msg)
IOError: [Errno 32] Broken pipe
Logged from file ipkernel.py, line 427
Other than that, it seems to be running OK, but I don't know why that might be happening / how I can find out more about why it's doing that