Pycharm build error: can’t find python libraries 3.6

Asked

Viewed 1,290 times

-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!

1 answer

-1

Modifying the interpreter in Pycharm

Go to Settings (File >> Settings), inserir a descrição da imagem aqui

In the side menu find the Project option and inside it Project Interpreter, on the right screen select the desired interpreter.

  • the problem is that none worked...

  • 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?

  • 1

    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

  • 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!

  • 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.

  • 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

  • which python3 /usr/bin/python3 , this is the output

  • I edited the question. Error persists!

  • 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

  • I will check again and return here!

  • Same thing: pytools.prefork.Execerror: error invoking 'nvcc --version': [Errno 2] No such file or directory: 'nvcc'

  • I did everything as you said! The compilation works only from the terminal. NO pyacharm, I get the error above!

  • 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.

  • then just edit the file /etc/Environment and add /usr/local/Cuda-9.2 Would that be it? I’ll test

  • I found that everything works if I run the IDE as root... Running with my common user gives the error!

  • then change the directory permissions so user can use!

Show 11 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.