i have installed VSC and set up the necessary dependencies for python.
Using a simple hello world example, i can run the file using run and debug option.
I can also run it by manually typing python hello.py in the terminal.
However, when i use the run button (top right hand corner), i get an error.
Can i check how to solve this?
Thank you.
Related
I am trying to setup the formatter "black" to work with PyCharm. I have tried setting it up with both the standard External Tools preferences and using the Files Watcher Plugin. Neither has worked for me.
I am getting these errors:
I have it installed in /Users/Scott/Library/Python/3.8/lib/python/site-packages/black.py and want it to run globally for all Python project files when I save.
This is how my preferences look:
I am new to Python and PyCharm and Stack Overflow for that matter, and am stilling setting this up. I appreciate your help.
Your problem is that you use .py file as a command. You need to add python to tell which program can execute this code.
Alternatively, you can use black executable if it is installed in your python environment.
I want to script with python using Notepad ++ but it works strangely, actually it does not work, so I have pycharm an everything is going well but in notepad ++ when I save file with .py and click run it does not work is there a step by step instruction to follow?
I have same problem with sublime text editor so I am lucky with just Pycharm all of the others has confused me please help me.
Notepad++ and sublime are text-editors and not interpreters. To run python script, you need a python interpreter. If you want to use notepad++, then write the python script in notepad++, open command prompt and run the python script from command prompt.
Assuming that you have python installrd, suppose you have created a file name "example.py" in the path "C:/Users/User/Desktop", then to run the script you will have to run the following commands:
$ cd "C:/Users/User/Desktop"
$ python example.py
I have no idea Why you gave me this -1 may be someone think that he knows everything so my idle.py is not the same location to my computer and when I assign location it pops up an error
sorry for error message image it is unable to copy
After installing the Python extension, I find myself not being able to debug. When I select any of the default launch configurations and press the green arrow to start debugging, it notifies me with the error message in the title. I am not using any external modules, I am simply trying to run a single line hello world program and this error still appears. I have tried reinstalling the extension, deleting the .vscode folder and checking the path of my Python interpreter.
I had the same problem, it was gone after I delete c:\users\username\ .code and reinstall vscode. hope that helps.
Lidong
I am not sure if this is a right place to ask this type of questions. I am a python beginner or programmer overall at this point. I am using Spyder to use python 3.6 (via Anaconda). I wrote a code that works fine when I run it in the current Ipython console. But I really need to run it in an external system terminal. In order to do so, I chose the following path: Run-> configuration per file -> execute in an external system terminal. That has been working fine. But now it refuses to work!
I validated that there is nothing wrong with my code by running something simple and saw that running via external system terminal does not work.
So far I deleted Anaconda and re-installed it. Could someone suggest what I should be looking for to diagnose the problem and fix it?
Thanks!
I had the same problem and noticed that unless the Working directory settings is set to "The directory of the file being executed", it won't work.
You can change it in "Run" > "Run configuration per file".
I made a virtualenv with tensorflow installed and I changed Python interpreter set to the location where the virtualenv is located at. When I ran the program, it gives the error:
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
I have the following lines written in my .bashrc file
export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
export PATH=${CUDA_HOME}/bin:${PATH}
Also, I found the libcudnn.so.5 file in the following path:
/usr/local/cuda-8.0/lib64
I encountered this error before I opened PyCharm and I did manage to install the correct cudnn version. The problem is, I can use
$ source [virtualenv_path]
to active the virtualenv and run python in terminal and everything works fine, no errors shown. The program also runs without error in Pycharm's terminal but it just gives me the above error whenever I click the run button. Could there still be something wrong with the environment variable? How do I fix it?
Unfortunately in pycharm you have to set CUDA_HOME and LD_LIBRARY_PATH inside the IDE. To do that go to the Run menu->edit configurations then choose your project. Then you click on the Environment Variables and add an entry for CUDA_HOME and LD_LIBRARY_PATH. When you have done that you can run directly from inside pycharm. I would also recommend setting the defaults to have these paths as well, so you don't have to do this for every project. Also it wouldn't hurt to make sure you have the interpreter from source [virtualenv_path] set while you are on this setting page. Let me know if you have trouble finding where to do this.
I've read this other Stackoverflow post: Pycharm environment different than command line, and it seems that the problem is that openning PyCharm in the normal way won't preserve the bash environment. The solution is to open PyCharm from the command line and everything works now. All you need to do is to open PyCharm using charm and everything works fine now.
I have searched a lot, but I didn't find the right solution for this question anywhere. I found the solution with my friends and I would like to share with you also.
If your Tensorflow works in terminal properly but doesn't work in Pycharm you have two solutions:
1- Open Pycharm from Terminal. For me:
pycharm-community
2- If you are using Unity, you need to edit .profile, because Pycharm doesn't preserve .bashrc: So, open a terminal and type:
gedit .profile
Then, add the following codes at the end of the opened file:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Save and exit. Now, you can work with Tensorflow in Pycharm without the necessity of opening the Pycharm form terminal.