qsub python import - python

I'm running a job on the cluster for the first time. I run it with the following command:
qsub -cwd -S /usr/bin/python myScript.py
I have a python script that starts with:
import time
import anotherScript
The error I get:
Traceback (most recent call last):
File "/opt/sge62/default/spool/hpc01/job_scripts/487174", line 11, in <module>
import anotherScript
ImportError: No module named anotherScript
the anotherScript.py is in the same directory as myScript.py.
What can I do to solve the problem? would appreciate any help

well, problem was solved by sys.path.append(currentWorkingDirectory). However, it's definitely not a nice way.

Related

Configure environment/path to run python scripts from terminale. For Mac

I found that when I run my scripts from environment - everything is OK.
But, when I try to run them from bash - I receive different errors with import modules. (ModuleNotFoundError, ImportError)
I didn't set the environment at all, so, please, tell me, what I should configure to succeed with it.
I use python 3.7
Received the next error:
Traceback (most recent call last):
File "main.py", line 1, in <module> from package_3.file3 import *
ModuleNotFoundError: No module named 'package_3'
The structure is:
package_1
file1.py
package_2
file2.py
package_3
file3.py
package_4
file4.py
What happens is, probably, that your working environment is python3, and when you run things in the shell, it's using python2. To solve it, run your script with python3 in the shell, as in:
python3 my_script.py

How to use miniedit in mininet?. Can anyone suggest the commands

I am not able to run the command $ sudo ~/mininet/examples/miniedit.py in mininet.When I type that command to use miniedit the output comes as Traceback (most recent call last):
File "./mininet/examples/miniedit.py", line 63, in
from mininet.log import info, debug, warn, setLogLevel
ImportError: No module named mininet.log
you have to execute miniedit.py from remote terminal "that has visualization" using ssh .
I had the same problem, all I did was change the default file path to desktop /usr/lib/python2.7/dist-packages/mininet/examples path to Desktop and it works

Apache Spark: How to use Python 3 with pySpark for development

So far I have done following:
import os
os.environ["SPARK_HOME"] = '/usr/local/spark/'
os.environ["PYSPARK_PYTHON"] = '/opt/conda/bin/python'
from pyspark import SparkContext
But when I run I get the error:
ssh://vagrant#127.0.0.1:2222/opt/conda/bin/python -u /home/vagrant/src/spark.py
Traceback (most recent call last):
File "/home/vagrant/src/spark.py", line 6, in <module>
from pyspark import SparkContext
ModuleNotFoundError: No module named 'pyspark'
Even If I try to run it without using Python3 path I get the same error.
The SPARK version of Python is given here:
/usr/local/spark/python
What wrong am I doing?
Ideally I want to use Python3 for my scripts.
try to:
import sys
sys.path.append('/usr/local/spark/python/pyspark')
or a direct way:
sudo ln -s /usr/local/spark/python/pyspark /usr/local/lib/python2.7/site-packages

ImportError with different python installations.

I am getting below ImportError while running a python file.
ImportError: No module named osgeo.gdal_array
!/usr/bin/env python
from osgeo.gdal_array import BandReadAsArray
However, if i try to import same from command line, it runs fine.
$ which python
/home/hduser/anaconda2/bin/python
$ python
>>> from osgeo.gdal_array import BandReadAsArray
>>>
Also, please see the below where i am getting the same ImportError.
$ /usr/local/bin/python2.7
>>> from osgeo.gdal_array import BandReadAsArray
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named osgeo.gdal_array
I figured out that there is something going on between different versions of python. But, i do not want to change the original source code.
How do i make my program run without changing anything within the code of calling python installed in anaconda explicitly?

how do i set my python path for success with my import statements?

I'm trying to install djangobb and when running manage.py syncdb it returns with
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manage
ImportError: No module named django.core.management
I know that deep in my python installation there is django/core/management, but I just don't know how to get manage.py to find it for me. Can someone point me in the right direction please?
Make sure that the base directory for where django/ lives is on your $PYTHONPATH

Categories