Issue using Black formatter in PyCharm - python-3.x

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.

Related

VSCode terminal is using the wrong python version

I have a new mac with python 3 installed from homebrew and visual studio code. I am not a python person by default I tend to use java but wanted to try a project for fun.
Just my terminal in VSCode has a system install of python 3.8 version that I am not using I want to use my brew install version as shown in screen shots. if I do echo $path it shows correct, my mac terminal shows correct and my VSCode python plugin has the correct version showing. I have rebooted several times in case it was cached.
I want to use the brew version 3.9.7. My project is failing to load imports such as "import requests" I assume because of this. The import fail error is.
Import "requests" could not be resolved from sourcePylancereportMissingModuleSource
I have installed and uninstalled requests many times always through VSCode command line.
Perhaps the values in $PATH of VS Code is in a different order than that of Terminal.app.
See https://github.com/microsoft/vscode/issues/70248 for more informations.
You can simply set "terminal.integrated.inheritEnv": false. This works well for me.
Try putting the following in settings.json:
"terminal.integrated.env.osx": {
"PATH": ""
}
Save the file, close any terminal window and restart VS Code.
You can read more here.
Go into VS Code settings: Code->Preferences->Settings. Type the following in the search box:
terminal.integrated.inheritEnv": false
Uncheck the option box beside the setting "whether new shells should inherit their environment from VS Code..." to set it to False.
Restart VS code and try again, you should have the same version of python as on your standard terminal.

VSCode doesn't recognize python interpreter

I am on arch linux, and for some reason VSCode doesn't find the python interpreter.
I have tried to set the python interpreter path to to be right (/bin/python3), and if I actually run a file then it works, but the python extension says I need to download python before using the extension and the auto complete doesnt work. Any Ideas? Any ways to debug this issue?
I'm having a similar issues, downgrading to Electron9.3.3-1 solved the issue for me while waiting for a potential fix.
Source: GitHub Issue
I found my solution with vscode-insiders. The current vscode python extension is already move on to rely on jupyter, another extension available only on vscode insiders.
Plus the vsc insiders logo looks cool..

Pycharm tensorflow ImportError but works fine with Terminal

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.

PyCharm: IDE does not seem to recognise Python 3 even with 3.x interpreter set

I am using the latest version of Pycharm(pycharm-2017.1) and have used Pycharm for a couple of years without issue. However, I have never written Python 3 scripts with it before, and have issues now. I am getting red underlined syntax errors which appear to clearly indicate that Pycharm doesn't understand that I'm using Python 3.
In 'Edit configurations', I have set Python 3.x to be the default interpreter... I'm not sure what I'm doing wrong.
Note: I have the correct python3 shebang lines in my scripts, and running them both straight from a terminal, or even by pressing 'run' in Pycharm works no problem.. this latter fact just adds to the mystery.
I also tried adding (with the '+' in 'Edit configurations', specific profiles for each of the scripts concerned, with Python3.x as the interpreters, to no avail)
Thanks for reading
The Edit configurations settings refers to the running options only.
To use python3 at project level you need to change the interpreter in File > Settings > Project: project-name > Project Interpreter
This allow to have correct syntax-checking, import-checking and others

Using wingIDE with a new module (not recognized)

Using my terminal, the code "from PIL import Image" works perfectly and is recognized by my computer. This allows me to get images using the path address.
Here is my issue, when I open wingIDE and try the same code...this module isn't recognized.
Is anyone familiar with wingIDE that can help me?
I would assume PyCharm people might have the same issue with possibly a similar fix, any advice??
Thanks,
Adam
Most likely Wing is using a different Python than the one you installed Pillow into. Try this on the command line:
import sys; sys.executable
Then set the Python Executable in Wing's Project Properties to the full path of that executable (or in Wing 101 this is set in the Configure Python dialog from the Edit menu). You'll need to restart any debug process and/or the Python Shell from its Options menus.

Resources