Every time I'm trying to use Emmet's Expand Abbreviation it gives me errors. First a pop up with Unknown Exception and then another pop up with python script plugin did not accept the script.
I tried reinstalling Notepad++ but that didn't help.
I'm running Windows 8 x64 & Notepad++ 6.6.9. This is the first time I'm using Emmet, after recently used the old Zen Coding. (Which works flawlessly.)
I have python 2.7 installed, if that necessary too.
I had the same problem as you.
This is the solution which worked for me:
emmetio/npp Bug ID #12: python script plugin did not accept the script
Basically, the problem lies in the Python Script plugin which will be automatically installed with Emmet.
Go to this link:
http://sourceforge.net/projects/npppythonscript/files/Python%20Script%200.9.2.0/
and download PythonScript_full_0.9.2.0 package.
Replace Notepad++'s Python package with PythonScript_full_0.9.2.0 and unpack the archive in Notepad++'s MAIN directory. (This is where notepad++.exe is.)
(Do NOT unpack the archive inside the plugins directory. That will not work. The python27.dll file needs to be in the same directory where notepad++.exe is.)
I am using Notepad++ v6.6.9 and it works now.
There is a newer version (PythonScript_1.0.8.0.msi ) available here:
http://sourceforge.net/projects/npppythonscript/files/latest/download?source=files
I had the exact same issue on two different computers, one Windows 7 and one Windows 8, both 64bit. I installed the MSI on the Win8 computer and it fixed the problem.
Check to see if it might be just the shortcut keys that aren't working by going to menuBar>plugins>emmet>expandAbbreviation. If clicking on that works after typing in some emmet syntax, but not when you type the shortcut key, reassign the shortcut keys. Here's what I did:
Look specifically at
menuBar>settings>shortcutMapper
under Main Menu-> "Insert Blank Line Above Current"
and see that ctrl+alt+enter is already assigned there.
Change that to something else (I did ctrl+alt+up), and you'll see that your shortcut keys are working for emmet.
You have 4 objects (2 files and 2 directories) that you have to sort:
Put the python27.dll file into the MAIN directory like so: %ProgramFiles(x86)%\notepad++\python27.dll
Put the others (doc directory, PythonScript directory, PythonScript.dll file) into %ProgramFiles(x86)%\notepad++\plugins\.
This works for Windows 8.
Also change the key shorcut by ctrl + E or some other.
Related
Heyy guys, I have a problem with opening .py files on mac. So if I just double click on the file, this error message pops up "The document XXX could not be opened. IDLE cannot open files in the “Python Script” format." 1
HOWEVER, if I open a python shell first from my application list. Then I can open the file by double clicking on it directly.
It seems that as long as there's a python shell open (empty new session or another opened file), the double clicking works. Otherwise it does not. I am using python 3.10 and Mac Big Sur 11.6.
Any idea what's wrong and how to fix it?
It might happen for not including the PATH variable properly that you should have added for Python 3.10. I have seen the difference from the Windows Operating System as the normal procedures (Python 3.9 and earlier) don't work on them properly just out of the box. The users need to add the PATH variable properly for Python 3.10.
You can also check this thread also. Check the Update 2 on that thread. Please also let us know whether that fixed your problem or not.
You can find an indepth solution to your problem here. https://bugs.python.org/issue38946
Previously, I had Python 3.7.4 installed & working great on Win10. Then, a 3rd party installer (unbeknownst to me) installed Python 2.7...which completely hosed my Python environment (ugh). After removing Python 2.7 and running a repair-reinstall of Python 3.7.4, it's mostly back up and running - except for the ability to drag and drop onto .py files.
Per Drag and drop onto Python script in Windows Explorer and Python Drag-and-drop broken, I've tried:
regedit:
HKCR\.py=Python.File (when I first checked, it was set to py_auto_file, so I did have to change this)
HKCR\Python.File\shell\open\command="C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\python.exe" "%1"
HKCR\Python.File\shellex\DropHandler= I've tried {60254CA5-953B-11CF-8C96-00AA00B8708C}, {86C86720-42A0-1069-A2E8-08002B30309D}, and {BEA218D2-6950-497B-9434-61683EC065FE}
With the above changes, I was able to get Python to launch when dragging-and-dropping onto .py files, but sys.argv does not contain the filename (only argv[0] is set, not argv[1]). Obviously I'm restarting Windows Explorer between each test. I've spent the past several hours searching & reading, but everything I've found pretty much contains some variation of the 3 changes above.
Any ideas why argv[1] would not be set when launching Python by dragging a file onto a .py script?
I managed to solve this by:
Do a repair-reinstall of Python 3
Do a repair-reinstall of Python Launcher
Create HKCU\Software\Classes\Python.File\shellex\DropHandler, with default={BEA218D2-6950-497B-9434-61683EC065FE}
Modify HKLM\Software\Classes\Python.File\shell\open\command, to set default="C:\Users\my_user_name\AppData\Local\Programs\Python\Python37-32\python.exe" "%1" %*
The contents of the file a.py are:
a = input()
print(a)
and fearless.txt contains the string : pink floyd.
Now, when I simply type in %a.py < fearless.txt at the command prompt (windows), it gives an error "lost.stdin".
However, when I type %python a.py < fearless.txt, no error occurs.
I don't understand this, given that .py is a recognized extension and is run by python. Shouldn't then, both be equivalent?
Note I'm using the symbol % in place of the actual directory.
( Python version : 3.4.3:9b73f1c3e601 and winXP-32 bit. )
It depends a bit on how the .py files are registered. It should work when the py.exe launcher is set up correctly. You can verify this by looking up the following key in the registry: HKEY_CLASSES_ROOT\Python.File\shell\open\command. The default value should be "C:\WINDOWS\py.exe" "%1" %*.
You can also try using the following instead:
type fearless.txt | a.py
I just noticed that you are using Windows XP. The problem you are seeing might be because of an old Windows bug with redirection. It was said to be fixed at some point, but maybe XP was still partially affected. I suggest you to update your system anyway because Windows XP is no longer supported by Microsoft.
If this is on a Unix system (as I'm guessing it is), you'll need to have a shebang line at the top of the file to tell the kernel that this is a file whose contents need to be executed by the specified interpreter. The .py extension is just a detail and is not used to decide "how to run" the given program.
When you try to run the file without the shebang, it's being executed by your current shell and that's what's giving you the errors. Python doesn't even come into the picture.
I'm trying to install IDLE2HTML from the following link in order to print from IDLE in color. I use Python 2.7 on a Mac.
I follow the instructions from the readme.txt, but when I reload IDLE nothing has changed. I don't have the Save As HTML option.
In the past I've installed and reinstalled Python a few times.
When trying to find my idlelib folder (as written in the readme instructions), I eventually found it under the path /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
Is my problem that my python is in /System/Library/?
Any ideas please?
I have not tried this extension, but the following may help. When you start Idle, select File / Path browser on the menu. You should see
_ sys.path
|
+ some_path/pythonxy/Lib/idlelib
|
+ some_path/python27.zip # or MAC equivalent
The first path tells you where the new files should be. If you click the +, you will see what file are there. What about IDLE2HTML.py? The next issue is whether you properly edited config-extensions.def. If you wait a few days for 2.7.9 and install it, you can try the new Options / Config-extensions dialog on the menu. That will show whether Idle can read the new information in the .def file. Or you can edit your question, paste in the new material you added, and comment on this answer, and I will take a look. However, given that the extension has been around for years, I presume that the addition in config-extensions.txt is correct.
I suspect that whenever you upgrade Python, config-extension.def will be overwritten and you will have to re-edit it.
If the problem is not a configuration problem with the IDLE2HTML Python IDLE extension like this answer (for the same question) explains about, it may be a problem with the code itself (this has happened with Python 3 IDLE). This can be checked by running IDLE using the Python file that starts it (<PYTHON LIBRARY DIR>\idlelib\idle.py where <PYTHON LIBRARY DIR> is the location of the standard library for the Python installation), in a command line interpreter (use <PYTHON EXECUTABLE DIR>\python.exe where <PYTHON EXECUTABLE DIR is the location of the executable files that start Python). It will launch IDLE and show any errors in the C.L.I..
Quote from Python idlelib module docstring:
Idle includes an interactive shell and editor. Use the files named idle.* to start Idle.
IDLE2HTML real error example:
A common problem is that IDLE2HTML version 2.0 (latest at time of writing) needs a simple code tweak to work with Python 3.x (a fixed version that works as part of the IDLEX Python module had this tweak). File comparison image (left is original file, right is IDLEX version in image); if the Python version is Python 3.x, import Tkinter needs to be changed to import tkinter as Tkinter and import tkFileDialog needs to be changed to import tkinter.filedialog as tkFileDialog:
Edwards suggestion of using the CLI for diagnosis was very useful. It exposed that the cgi.escape attribute does not exist for Python 3.
I changed the IDLE2HTML.py line 74 from "out.append(cgi.escape(content))" to
"out.append(content)" and after a re-boot it all worked!
Later: well almost... better to replace "import cgi" with "import html and then cgi.escape() with html.escape()
If using Win10 you will need super-admin rights to change IDLE2HTML.
Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do "import os" followed by "os.chdir("")" but that's kind of troublesome. It'd be great if there is a conf file that I can edit and change that setting, but I am unable to find it.
In particular, I've looked into my OS (Ubuntu)'s desktop entry '/usr/share/applications/idle-python3.2.desktop', which doesn't contain a conf file, but points to '/usr/lib/python3.2/idlelib/PyShell.py', which points to config-*.def conf files under the same folder, with 'config-main.def' being the most likely candidate. However I am unable to find where the default path is specified or how it can be changed.
It seems that the path is hard-coded in PyShell.py, though I could be wrong with my limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.
I actually just discovered the easiest answer, if you use the shortcut link labeled "IDLE (Python GUI)". This is in Windows Vista, so I don't know if it'll work in other OS's.
1) Right-click "Properties".
2) Select "Shortcut" tab.
3) In "Start In", write file path (e.g. "C:\Users...").
This is also my answer here: Default save path for Python IDLE? Let me know if this works!
I've found a solution after looking into PyShell.py:
Create a python file under a preferred directory, in my case '~/.idlerc/init.py', and copy/paste the following lines:
import os
os.chdir('<your preferred directory>')
Pass "-r '~/.idlerc/init.py' " argument to the IDLE startup command, like the following (your exec location and name may vary depending on OS, etc):
/usr/bin/idle-python3.2 -n -r ~/.idlerc/init.py
Just use a shell script such as:
#!/bin/bash
cd /Users/pu/Projects/L-Python
/usr/bin/idle
and run that instead of stock idle. The example is on OS X, adapt to your system.
I'm new to python and learning from 'Dive into Python' by mark Pilgrim (can be found online free)
the answer is in chapter 2.4 - hope he doesn't mind me pasting it here as its also plugging his book and is in the GPL
Before you go any further, I want to briefly mention the library
search path. Python looks in several places when you try to import a
module. Specifically, it looks in all the directories defined in
sys.path. This is just a list, and you can easily view it or modify it
with standard list methods. (You'll learn more about lists later in
this chapter.)
Example 2.4. Import Search Path
import sys
sys.path
sys.path.append('/my/new/path')
It's a good book I am a programmer - usually I find learning from books sends me quickly to sleep - not the case here ....
All I had to do here (Linux Mint 18.2 Xfce) ...
Just add path in line "working directory" = "Arbeitsverzeichnis"
It can change depending on where you installed Python. Open up IDLE, import os, then call os.getcwd() and that should tell you exactly where your IDLE is working on.
One default path is specified in idlelib.IOBinding.IOBinding.dirname or idlelib.IOBinding.IOBinding.filename
Ubuntu
So my idle-python3.desktop
file in /usr/share/applications looks like this:
[Desktop Entry]
Name=IDLE (using Python-3)
Comment=Integrated Development Environment for Python (using Python-3)
Exec=python3 -c "import idlelib.IOBinding, os; idlelib.IOBinding.IOBinding.dirname='/DEFAULT/DIRECTORY';import idlelib.idle"
Icon=/usr/share/pixmaps/python3.xpm
Terminal=false
Type=Application
Categories=Application;Development;
StartupNotify=true
To use it you need to set /DEFAULT/DIRECTORY to your desired directory, copy it with root rights into /usr/share/applications. You can also use it for Python 2 but then you need to replace the 3s with 2s.
ConfigFiles
There are also extensions that can be loaded. These must be modules and you specify them by module name. The config files for IDLE are located in HOME/.idlerc and parsed with a configparser. I did not get further with this.
Here's a way to reset IDLE's default working directory for MacOS if you launch Idle as an application by double-clicking it. You need a different solution if you launch Idle from a command line in Terminal. This solution is a permanent fix. You don't have to rechange the directory everytime you launch IDLE. I wish it were easier.
The idea is to edit a resource file inside of the IDLE package in Applications.
Start by finding the the file. In Finder, go to IDLE in Applications (in the Python folder) as if you wanted to open it. Right click and select "show package contents". Open Contents, then open Resources. In Resources, you'll see a file called idlemain.py. This file executes when you launch idle and sets, among other things, the working directory. We're going to edit that.
But before you can edit it, you need to give yourself permission to write to it. To do that, right click on the idlemain.py and select get info. Scroll to the bottom of the getinfo window and you'll see the Sharing & Permissions section. On the bottom right there's a lock icom. Click the lock and follow the prompts to unlock it. Once it's unlocked, look to the left for the + (under the list of users with permissions). Click it. That will bring up a window with a list of users you can add. Select yourself (probably the name of your computer or your user account) and click Select. You'll see yourself added to the list of names with permissions. Click where is says "Read only" next to your name and change it to "Read & Write". Be careful not to change anything else. When you're done, click the lock again to lock the changes.
Now go back to idlemain.py and open it with any text editor (you could use Idle, TextEdit, or anything. Right under the import statement at the top is the code to change the default working directory. Read the comment if you like, then replace the single line of code under the comment with
os.chdir('path of your desired working directory')
Mine looks like this:
os.chdir('/Users/MyName/Documents/Python')
Save your changes (which should work because you gave yourself permission). Next time you start Idle, you should be in your desired working directory. You can check with the following commands:
import os
os.getcwd()
This ought to be the number one answer. I have been playing around this for an hour or more and nothing worked. Paul explains this perfectly. It's just like the PATH statement in Windows. I successfully imported a module by appending my personal "PythonModules" path/dir on my Mac (starting at "/users/etc") using a simple
import xxxx command in Idle.