-2
Operating System: Ubuntu 16.04 64 bits Python 3.6 installed via apt-get
When compiling a program in the terminal using:
python3.6 programa.py
No error is presented.
When running the same program with pycharm or Wing Python IDE, with python3.6, I get errors from libraries (e.g., numpy, pycuda) not found.
The code executed:
#https://documen.tician.de/pycuda/tutorial.html
import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
import numpy
a = numpy.random.randn(4,4)
a = a.astype(numpy.float32)
a_gpu = cuda.mem_alloc(a.nbytes)
cuda.memcpy_htod(a_gpu, a)
mod = SourceModule("""
__global__ void doublify(float *a)
{
int idx = threadIdx.x + threadIdx.y*4;
a[idx] *= 2;
}
""")
Error (only in the IDE running from the terminal there is no error):
pytools.prefork.ExecError: error invoking 'nvcc --version': [Errno 2] No such file or directory: 'nvcc'
Question: how to do for Ides used the same python3.6 installation that works when calling on the finish? How to find out which installation has all the libraries installed?
PS: I figured out the problem. I just don’t know how to fix it. Python Ides aren’t seeing the environment variables and I don’t know how to set them!
the problem is that none worked...
– Ed S
i tried this but could not find a "python path" that worked.... How to find the same path as python3 that I used in the terminal?
– Ed S
1) Open the Ubuntu Terminal with CRTL + T 2) In the terminal type: which python3 /usr/local/bin/python3 3) With the above command it gives you the path to any file/executable
– weltonvaz
I figured out the problem. I just don’t know how to fix it. Python Ides aren’t seeing the environment variables and I don’t know how to set them!
– Ed S
In Ubuntu you don’t need to do this, because you can have several versions of python installed. You only need to set in the IDE or EDITOR configuration in the Pycharm case! As shown above.
– weltonvaz
Add the following lines at the end of the file . bashrc which is in your home directory: PYTHONPATH=/usr/local/bin/python3 </br> export PYTHONPATH
– weltonvaz
which python3 /usr/bin/python3 , this is the output
– Ed S
I edited the question. Error persists!
– Ed S
You did what was proposed, added the python environment variable at the end in the file . bashrc that is in your home? Instead of using PYTHONPATH=/usr/local/bin/python3 it uses what it is configuring on your machine: PYTHONPATH=/usr/bin/python3 and on the bottom line type: export PYTHONPATH. Close the file . bashrc, in the terminal type: source . bashrc
– weltonvaz
I will check again and return here!
– Ed S
Same thing: pytools.prefork.Execerror: error invoking 'nvcc --version': [Errno 2] No such file or directory: 'nvcc'
– Ed S
I did everything as you said! The compilation works only from the terminal. NO pyacharm, I get the error above!
– Ed S
I already fixed this once. It had to do with how Ubuntu stores a separate $ PATH variable for sudo as opposed to the ordinary user. Once I made the necessary changes to /etc/Nvironment to add the nvcc path /usr/local/Cuda-8, everything was fine.
– weltonvaz
then just edit the file /etc/Environment and add /usr/local/Cuda-9.2 Would that be it? I’ll test
– Ed S
I found that everything works if I run the IDE as root... Running with my common user gives the error!
– Ed S
then change the directory permissions so user can use!
– weltonvaz