Quantcast
Channel: ActiveState Community Site - ActivePython discussion
Viewing all 75 articles
Browse latest View live

Need Help Please

$
0
0

Need help completing my Python project. So far I need to convert an ISBN-10 to a ISBN-13 and also to convert an ISBN-13 to a ISBN-10. Also reading ISBNs from a file and storing correct results in a file. It's due tonight by 11:55pm. Major grade and would greatly appreciate. Here is what I have so far

AttachmentSize
Python1.JPG73.07 KB
Python2.JPG88.38 KB

Python redis returns consequences with appended textual content to result

$
0
0

I just commenced to apply redis with python, from command line and in jupyter notebooks and i am getting appended text to each locations. code is as follows:

import redis
r = redis.StrictRedis(host='xxx.xxx.xxx.xxx', port=yyyy, db=0, password='$$$$$$$')

r.hmset('hmfoo', { 'name': 'myname', 'username': 'myusername'})
True

r.hget('hmfoo', 'name')
b'myname'<----- why is the 'b' appended here??

it really works as you assume with the proper values stored in redis and the whole thing, simply now not positive why the b is displaying on the start of the text?

print a persian file by thermal printer and python-escpos mnodule

$
0
0

hello friends...
i want to print a persian file by thermal printer..
i can print an english file esily..but i face the proble while printing persian text..
i think i don't do some principles...i have studied about unicode encodeand decode in python..but it seems it isn't enough
please guide me

in the first code, i used the different codepages, but my output from the printer is just question mark ""?"" instead of the persian words

in the second code
the printer prints the obscure letters...
i tried the different codepages..but it wasn't usefull

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Print an Arabic string to a printer.
# Based on example from escpos-php

# Dependencies-
# - pip install wand python-bidi python-escpos
# - sudo apt-get install fonts-hosny-thabit
# - download arabic_reshaper and place in arabic_reshaper/ subfolder

import arabic_reshaper
#from escpos import printer
from escpos.printerimport Usb
from bidi.algorithmimport get_display
from wand.imageimport Image as wImage
from wand.drawingimport Drawing as wDrawing
from wand.colorimport Color as wColor

p = Usb(0x04b8,0x0e15,0)

p.codepage="cp720"  #???????

# Some variables
#fontPath = "/usr/share/fonts/opentype/fonts-hosny-thabit/Thabit.ttf"
textUtf8 = u"????"
tmpImage ='my-text.png'
printWidth =550

# Get the characters in order
textReshaped = arabic_reshaper.reshape(textUtf8)
textDisplay = get_display(textReshaped)

# PIL can't do this correctly, need to use 'wand'.
# Based on
# https://stackoverflow.com/questions/5732408/printing-bidi-text-to-an-image
im = wImage(width=printWidth, height=36, background=wColor('#ffffff'))
draw = wDrawing()
draw.text_alignment='right';
draw.text_antialias=False
draw.text_encoding='utf-8'
draw.text_kerning=0.0
draw.font_size=36
draw.text(printWidth,22, textDisplay)
draw(im)
im.save(filename=tmpImage)

# Print an image with your printer library
p.set(align="right")
p.image(tmpImage)
p.cut()/<python>

the second code :

<python>
from escpos.printerimport Usb
""" Seiko Epson Corp. Receipt Printer M129 Definitions (EPSON TM-T88IV) """

p = Usb(0x04b8,0x0e15,0)

p.codepage="iso8859_6" 

# Print text
p.text(u"????\n")

p.cut()
/<python>

Install Python 3 as WSH engine

Viewing numpy variables in python3/Komodo11

$
0
0

I recently ported my code to Python3 and upgraded to Komodo11. One of these things had a big impact on the way that numpy variables are displayed. For example, any ndarray type now shows a whole bunch of extra information in addition to the data I specifically assigned to the variable. When the variable is expanded I see 'T', 'base', 'ctypes', etc., etc., and many of these appear to be recursive, repeatedly expanding to the same thing. ...and this has nothing to do with displaying hidden variables.

What exactly am I seeing here? Is this a new feature of Komodo11, a Komodo bug, or a feature/bug of Python3? Some of the new data is potentially useful but it is all too much for normal use. Is there any way to turn it off?

I am seeing this with my Windows installation. I've been trying to go back to see how things looked with python3 and Komodo10 on a spare linux box but I've got the installations so buggered up now I'm going to need to start over. As you can see, it has got me a little freaked out.

Has anyone else experienced this? Can you explain it to me?

Many Thanks,
eesnyder@eesnyder.org

New Recipe Posts

$
0
0

I have some recipes in Python I think would be valuable to this community but the recipe post feature appears to be turned off. Is there a way I can post my recipes?

ActivePython in ALM VAPI-XP Script

$
0
0

Bonjour
Je souhaite exécuter du un script Python depuis HP ALM, de la même manière que je peux exécuter du code VBS. J'ai installé ActivePython sur mon poste local, et pourtant mon script ne s'exécute pas. Le code du script se résume à un 'print("test")'. Comment faire pour exécuter le script python depuis ALM?
Merci =)


Hi,
I would like to run Python in ALM. I installed ActivePython on my local computer but the script does'nt run. The script is 'print("test")'. How can I run the python script from ALM???
Thank you =)

Install other Packages

$
0
0

Hello,

I install ActivePython but now i want to install others packages which are not include in active python (like mechanize for exemple). I install them by typing sudo apt-get install python-mechanize in my terminal but when i open python so it's active python now, i can't import them. My question is : how to import the installed packages which are not in active python ?

Thanks,

Pierre.


security plugins for active python

$
0
0

So I've been stepping into the field of cybersecurity using python and am in a crossroad right now as far as my dedicated IDE goes. I love and started out using Komodo when I picked up on Python and now that I am transitioning into cyber security I am broadening my workbench and am looking for plugins for Komodo that will help detect security flaws easier. I know eclipse and vs have them but I am so used to Komodo and am trying to avoid turning towards another IDE. Is there anything like this or any security plugins that can help for Komodo?

How do I import the Paho MQTT Library to Komodo IDE?

$
0
0

I've been trying to import the Paho MQTT Library (https://github.com/eclipse/paho.mqtt.python) into Komodo IDE.

What I have done so far:
> Copied the Paho folder into python>lib>site-packages>
> In Komodo preferences, I set the path under Python language to add the folder.
> Changed/tried different paths for Python, Pip, etc.

Nothing seems to work so far. Whenever I run a python script, I see this error:

Traceback (most recent call last):
  File "C:\Users\kvin\workspace\paho_projects\mqtt_test0.py", line 1, in <module>
    import paho.mqtt.client as mqtt
ImportError: No module named paho.mqtt.client

Can someone tell me if I'm doing something wrong here? Thanks

How can i install a package?

$
0
0

I have installed Active Python 3.5.4 on Windows 10 x64.

I have upgraded the pip package by typing

python -m pip install -U pip

I have installed the package "whois" by typing

pip3 install whois

I have created a file "whois.py" with the content:

import whois

When i execute the whois.py file, a window opens and is asking me for a file "ActivePython-3.5.4.3504-win64-x64-404899.exe.msi".

I don't have that file and i can't find on the ActivePython download page. There is only an exe file to download. MSI files are unavailable.

So i am unable to install the package.

Please what am i doing wrong?
How can i install the package?

Thank you!

AttachmentSize
activepython_moduleinstall.png33.22 KB
activepython_moduleinstall_whois.png18.85 KB

Package "whois 0.7" does not work on Windows 10

$
0
0

I tried to test the package according to the description https://pypi.python.org/pypi/whois

>>> import whois
>>> domain = whois.query('google.com')

But i only get the error

AttributeError: module 'whois' has no attribute 'query'

What is wrong there?
Thank you!

ILDE SOCKET

$
0
0

Hello all,

I am Running windows xp sp3, MS Security Essentials, and Windows Firewall. I installed ActivePython-2.7.1.4-win32-x86.

When I run the IDLE I get a message that says:
Socket Error: No connection could be made because the target machine actively refused it.

Does anyone know what I could do to resolve this issue?

Odd behavior after upgrading package with pip.

$
0
0

I am seeing some very odd behavior with ActiveState ActivePython after using pip to install a package.

1. Install ActiveState ActivePython 3.6.

2. Run a Python script using the file association, that is just by calling the script itself. All is well in the universe.

3. Use pip to upgrade a package that is included in ActiveState ActivePython. For example, run the following command.

python -m pip install --upgrade pip

4. Run a Python script using the file association, that is just by calling the script itself. The universe blows up.

5. The following dialog box is displayed.

[ActivePython 3.6.0 Build 3600 (64-bit)]

Please wait while Windows configures ActivePython 3.6.0 Build 3600 (64-bit).

[Cancel]

6. This leads to a "The feature you are trying to use is on a network resource that is available" dialog box.

7. Since I have not idea what it is looking for, I hit cancel in this dialog box.

8. A "Fatal error during installation" message is displayed.

9. Focus returns to the command prompt.

10. The script fails to run.

The end result is that running a script by calling the script directly is completely broken. You have to uninstall ActivePython and reinstall it to get the just run script feature to work.

You are forced to put up with out of date packages since any attempt to upgrade an out of date package causes this to break.

Adding class types to engine's namespace

$
0
0

Hello,
I tried this one in the other forum, I am trying my luck here:
I was wondering if it's possible to add class types defined in a type library calling AddTypeLib() instead of adding a specific instance using AddNamedObject(). I tried to do it on IActiveScript interface to VBScript and to Python in some implementation of an embeddable scripting editor and though the return code from AddTypeLib was OK- the class types from the type library were not familiar to the engine.
Is it possible with Python? how should I address this class once it's in?

Thanks!


Viewing all 75 articles
Browse latest View live




Latest Images