cygwin version of idle has erroneous I/O handling - cygwin

I am using idle (python 2.5) via cygwin on a windows vista machine and when I try to open an already existing .py file I see the full file path
/home/aaron/C:/cygwin/home/aaron/script.py
on the banner of the freshly openned file window when I expect simply
/home/aaron/script.py
In addition, the file appears blank which makes sense...basically idle is opening up a nonexistent file in some fictitious path. So what is causing the problem and how to fix? Anyone?

I have the same problem, but I found a workaround is to use File->Path Browser menu. From there I can find the .py file and open it by double clicking the file name.

Related

Pycharm throws FileNotFoundError after refactor for some file [duplicate]

Recently, I'm unable to use relative paths in my code while using PyCharm. For instance, a simple open('test.txt', 'r') will not work - whereupon I am sure the file exists in the same level as the running py file. PyCharm will return this error.
FileNotFoundError: [Errno 2] No such file or directory:
After reading answers online on StackOverflow, I have tried multiple options including:
Changing test.txt to ./test.txt
Closing project, deleting the .idea folder, open the folder with code.
Reinstalling as well as installing the latest version of PyCharm.
Invalidating caches and restarting.
None of these options have worked for me. Is there someway I can tell PyCharm to refresh the current working directory (or even to see where it thinks the current working directory is)?
Edit: I should note that running the script in a terminal window will work. This appears to be a problem with PyCharm and not the script.
Change:
Run > Edit Configurations > Working directory,
which sets the working directory for a specific project. (This is on a Mac)
I have Pycharm 4.5, so things might have changed a bit.
Try going to Settings > Project > Project Structure
On this dialog, click your folder that has the source code in it, and then click the blue folder in the menu to note it as "source" folder. I believe this fixes a lot of the path issues in Pycharm
Here is the link to "content roots": https://www.jetbrains.com/pycharm/help/content-root.html
Current version 2019.2 somehow ignores "source root" from the "project structure". Here's how to actually enforce it:
Run -> Edit Configurations -> Python -> "Edit Templates" -> fill out "Working Directory"
__file__ refers to file path. So you can use the following to refer file in the same directory:
import os
dirpath = os.path.dirname(__file__)
filepath = os.path.join(dirpath, 'test.txt')
open(filepath, 'r')
In PyCharm, click on "run/edit configurations..."
Then find your script file in the "Python" dropdown menu. Check the "Working Directory" entry and change it if necessary.
EXACT ANSWER TO SOLVE THIS ISSUE ,,
GO TO EDIT CONFIGURATION (just LEFT side of GREEN CODE RUNNER ICON)
click on python (not any specific python script) ONLY SELECT PYTHON
then below right side click on [edit configuration templetes]
select current working dir by going into those blocks
It will change the CWD of all python file that exists in project folder..
then all file will understand the RELATIVE PATH that starts from your actual project name..
i hope this will resolve all your issue related path.
Sometimes it is different. I solved my problem by clicking "Run" at the Pycharm's toolbar and then "Edit Configurations..." and I change my Interpreter to another actual one. Just changing it in the settings does not help, but this opperation already does ;)
I too had the same issue few minutes ago...but,with the latest version of PyCharm it is resolved by simply using the relative path of that file..
For instance, a simple f = open('test', 'r') will work.
A little clarification for mac users. In mac, what #andere said above is correct for setting working directory. However, if your code is in a different folder, say working_dir/src/ (like classic java/scala file structure) in that case you still need to set your Sources Root. In mac's PyCharm this can be done by right clicking on the src/ folder > Mark Directory as > Sources Root. Helped me with lot of similar import issues. Hope this helps someone.

I am not allowed to run a python executable on other pcs

I was doing a game in tkinter, then I make it executable with PyInstaller and sent it to my friends so they can run it and tell me how it feels.
It seems that they could download the file, but can't open it because windows forbade them telling that it's not secure and not letting them choose to assume the risk or something.
They tried to run as administrator and still nothing changed.
What should I do or what I should add to my code so that windows can open it without problem and why windows opens other executable files without saying that(current error that my executable gets)?
compress it as a .zip file and then it will most probably work
or install NSIS and create a windows installer for it.
I finally figured out what I had to done
When the dialog appeared u need to click more info and then it will display a Run Anyway button

Error parsing gtk-icon-sizes string: ' '

Sorry I am pretty new to Linux machine and Ubuntu.
Here is what I did:
I tried to install PhpStorm 2016.3.2 on Linux machine (Ubuntu) by downloading the .gz file from JetBrains site.
I extracted the PhpStorm-2016.3.2.tar.gz file inside /home/[USERNAME]/apps/phpstorm/ folder.
I went inside bin/ folder and typed command line ./phpstorm.sh using Terminal.
It opens the PhpStorm application, but..
Error message:
It shows Error parsing gtk-icon-sizes string: ' ' message while opening the app.
Problem:
Application cannot stay open unless this Terminal stays open.
PhpStorm's icon is not created on my machine, so every time if I want to open PhpStorm, I have to open Terminal and type ./phpstorm.sh.
Question:
While I was looking for solution, I got a feedback that I need to edit .bashrc file to make it executable in that path. What does it mean?
Do I have to modify the path inside "jediterm-bash.in"–> function load_interactive_configs?

Can't run .run file using cygstart

I am trying to run a .run file in cygwin, but I always seem to get this error:
Unable to start '~.run': There is no application associated with the given file name extension.
I needed to be a superuser, so I tried using the command: cygstart --action=runas "$#"
I read somewhere that cygstart is for invoking registered Windows handler, so this may be the problem, but I am unsure. Is there any way that I can run my .run file as a superuser using cygwin?
Well, as has been said, no application is associated with .run files on your
system. So you can do that one of two ways
Call the file with the program, example
cygstart notepad.exe ~.run
Tell the registry what to do with unknown extensions
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Unknown]
#=""
[HKEY_CLASSES_ROOT\Unknown\shell\Open\command]
#="notepad.exe \"%1\""
This question is not related to Cygwin but rather to Windows. cygstart works the same as Windows' start. That means, if you use [cyg]start file.extension it works very similarly as if you double-click on that file in Windows Explorer.
Therefore if you configure Windows to do what you need when you double-click on your *.run file, cygstart will work fine too.
I think that easier is to use appropriate extension which Windows already knows. It depends on what you have inside your *.run file. If it's executable, use exe extension, if it's batch script, use cmd or bat, if it's JavaScript, use js etc.
If you use Linux or some derivation, you need to execute the .run file with an absolute path, even if you have already navigated to the appropriate directory containing the file. See here:
http://the-chronicon.blogspot.com/2011/08/execute-run-file-in-current-folder-from.html

Executing :mksession in vim generates error

When i try and save a session using :mksession, i get the following error:
E190: Cannot open "Session.vim" for writing
I have checked the permissions for the current directory, and they are fine. (I can and have been saving my files to this directory.)
Anyone got any ideas?
I am using Gvim 64-bit , on the windows 7 os.
Thanks for any insight!
Russ
"Session.vim" seems to be created at the path of the current file you are editing.
If you are viewing a system file, in a directory where you don't have permission to write, it is likely that it won't work. If you want to be sure this is the case, try to launch vim with "sudo vim/sudo gvim" and check again if it works or not.

Resources