Python version: 2.7.8
P4Python version: P4PYTHON/NTX86/2014.1/807760 (2014.1/807760 API) (2014/03/18)
Client OS: Win2k8 Server
Python script:
from P4 import P4, P4Exception
p4agent = P4()
p4agent.port = "ssl:my-perforce-server.com:1666"
p4agent.user = "abc"
p4agent.password = "a$3"
p4agent.connect()
p4agent.run_login()
Output:
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\PythonSync\P4Sync.py", line 44, in <module>
getLatestRevision()
File "C:\Users\Administrator\Desktop\PythonSync\P4Sync.py", line 41, in getLatestRevision
initP4()
File "C:\Users\Administrator\Desktop\PythonSync\P4Sync.py", line 36, in initP4
p4agent.connect()
File "c:\python27\lib\site-packages\P4.py", line 678, in connect
P4API.P4Adapter.connect( self )
P4Exception: [P4.connect()] Connect to server failed; check $P4PORT.
SSL library must be at least version 1.0.1.
p4agent.identify() output:
Perforce - The Fast Software Configuration Management System.
Copyright 1995-2014 Perforce Software. All rights reserved.
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/)
See 'p4 help legal' for full OpenSSL license information
Version of OpenSSL Libraries: OpenSSL 1.0.1d 5 Feb 2013
Rev. P4PYTHON/NTX86/2014.1/807760 (2014.1/807760 API) (2014/03/18).
The path to OpenSSL (lib) is set in the Path variable.
I also checked 'p4 set' on the client machine (from where I am trying to connect to the perforce server) and I see that all environment variables are properly set.
Can someone please let me know how to resolve this?
I believe the problem is that you are linking with the wrong Openssl library. The output of P4.identify() is misleading: this is the version of the OpenSSL the API was compiled with, not the version you are linking against.
Where did you get that version of P4Python from? Did you compile it yourself or did you download it from some other site?
If you want to use a ready-made version of P4Python for Windows Python 2.7 and 3.4 32bit and 64bit, please have a look at https://swarm.workshop.perforce.com/projects/p4pythonlib/files/p4pythonlib/bin. Let me know if you have any problems with these builds.
Related
When I run in 32 bit python,
import pyvisa
rm = pyvisa.ResourceManager()
I get this error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyvisa\highlevel.py", line 3015, in new
visa_library = open_visa_library(visa_library)
File "C:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyvisa\highlevel.py", line 2929, in open_visa_library
return cls(argument)
File "C:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyvisa\highlevel.py", line 175, in new
raise OSError("Could not open VISA library:\n" + "\n".join(errs))
OSError: Could not open VISA library:
function 'viOpen' not found
Here is what I have tried so far:
re-installed with pip
$ pip install -U pyvisa
Here is some info of the install:
python -m visa info
C:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\lib\site-packages\visa.py:13: FutureWarning: The visa module provided by PyVISA is being deprecated. You can replace import visa by import pyvisa as visa to achieve the same effect.
The reason for the deprecation is the possible conflict with the visa package provided by the https://github.com/visa-sdk/visa-python which can result in hard to debug situations.
warnings.warn
Machine Details:
Platform ID: Windows-10-10.0.18362-SP0
Processor: Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
Python:
Implementation: CPython
Executable: C:\Users\latshaw\AppData\Local\Programs\Python\Python38-32\python.exe
Version: 3.8.5
Compiler: MSC v.1926 32 bit (Intel)
Bits: 32bit
Build: Jul 20 2020 15:43:08 (#tags/v3.8.5:580fbb0)
Unicode: UCS4
PyVISA Version: 1.11.3
Backends:
ivi:
Version: 1.11.3 (bundled with PyVISA)
#1: C:\windows\system32\visa32.dll:
found by: auto
bitness: 32
Could not get more info:
function 'viOpen' not found
I am not sure what is going wrong here. From my research, it seems that the biggest 2 ways that people make mistakes are in mismatching a 32 version of pyvisa and a 64 bit version of IDLE (both of mine are 32 bit) and the other is in naming the file visa.py (which I am not doing).
Any help is greatly appreciated, cheers!
After some more digging, I found that this is a problem for python 3.8 as it does not load the DLL files correctly (something about an environmental PATH). In my specific case, I am interested in loading the keysight visa, so the below works for me.
import os
os.add_dll_directory('C:\\Program Files (x86)\\Keysight\\IO Libraries Suite\\bin')
import pyvisa
rm = pyvisa.ResourceManager('ktvisa32')
and now rm returns:
rm <enter>
<ResourceManager(<IVIVisaLibrary('ktvisa32')>)>
I think that this is the fix to my problem. However, I am running 'offline' right now and am not able to access the key-sight test equipment to see if I can talk to them over the python scripts. My fingers are crossed :)
Thanks for reading :)
Good day,
I'm a student and I would just like to ask for a minute of your time.
I'm working on a barcode reader connected via USB port to a board name Arduino Yun. This board runs a version of embedded linux derived from OpenWrt using a microprocessor named Atheros AR9331
I would like to ask you, what's necessary to make the Python Evdev binding (python-evdev.readthedocs.org/en/latest/), to be able to run in this type of MIPS microarchitecture? At the momento, it's only for Ubuntu and ArchLinux.
I'm kind of guessing that cross compilation would be needed, or the indication of the usage of a specific C compiler inside this linux.
The current python version supported for OpenWrt is 2.7.3
I already know , if you compile C code in your PC, the resulting executable will only run in this type of architecture. If you use that compiled program inside the microprocessor, it wont work.
I've used this binding without trouble within ubuntu in my PC. I followed the instructions, python setup.py install, with a previous installation of setuptools, and it worked just fine.
But regarding OpenWrt, this was not the case.
The python script I'm using requires this library within the first line of code in order to reach the data from the device (it works like a keyboard /dev/input/event0):
#!/usr/bin/env python
from evdev import InputDevice, ecodes, list_devices
from select import select
I've seen suggestions of copying the entire library inside the arduino, and run the script inside the same folder. But it doesn't work, since the evdev module has files created with the architecture of the PC and not the MIPS.
So, what are the messages displayed for the error?
If you run python setup.py install in Openwrt to try to install the evdev binding, this appears on screen:
File "setup.py", line 10, in <module>
from setuptools.command.develop import develop
ImportError: No module named setuptools.command.develop
It's obvious from here that you need the module aforementioned. So, I tried to install it with this script (pypi.python.org/pypi/setuptools):
python ez_setup.py
And the output shows this:
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.zip
Traceback (most recent call last):
File "ez_setup.py", line 332, in <module>
sys.exit(main())
File "ez_setup.py", line 327, in main
downloader_factory=options.downloader_factory,
File "ez_setup.py", line 287, in download_setuptools
downloader(url, saveto)
File "ez_setup.py", line 209, in download_file_curl
_clean_check(cmd, target)
File "ez_setup.py", line 169, in _clean_check
subprocess.check_call(cmd)
File "/usr/lib/python2.7/subprocess.py", line 511, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['curl','https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.zip', '--silent', '--output', '/mnt/sda1/evdev-0.4.6/setuptools-11.3.1.zip']' returned non-zero exit status 60
I pressume this output is due to the fact that pypi doesn't exist for the python 2.7.3 in OpenWrt , only for newer versions and other architectures. Evedv binding is requiring the setuptools module in order to make things easier and standard, but if the binding is not supported for the target architecture, what's needed to be able to use it anyways?
Thanks for your time,
Good day everyone,
The solution was provided by Georgi Valkov. He is the creator of the python-evdev binding. I contacted him directly, and he was so kind that he cross compiled a version for the OpenWrt / Yun .
You can install the package using the openwrt package manager - opkg. The installation process is along the lines of:
$ opkg update
$ opkg install /path/to/python-evdev_0.4.7-1_ar71xx.ipk
To verify that the install was successful:
$ opkg files python-evdev
/usr/lib/python2.7/site-packages/evdev-0.4.7-py2.7.egg-info
/usr/lib/python2.7/site-packages/evdev/genecodes.py
/usr/lib/python2.7/site-packages/evdev/ff.py
/usr/lib/python2.7/site-packages/evdev/_input.so
/usr/lib/python2.7/site-packages/evdev/device.py
/usr/lib/python2.7/site-packages/evdev/events.py
/usr/lib/python2.7/site-packages/evdev/__init__.py
/usr/lib/python2.7/site-packages/evdev/ecodes.py
/usr/lib/python2.7/site-packages/evdev/_ecodes.so
/usr/lib/python2.7/site-packages/evdev/util.py
/usr/lib/python2.7/site-packages/evdev/uinput.py
/usr/lib/python2.7/site-packages/evdev/_uinput.so
This works just fine. Thanks.
PS. If someone needs the file, please contact me. Georgi sent me this address, but I didn't download the file from there because he sent it to me over email.
https://github.com/gvalkov/openwrt-packages-yun/blob/master/lang/python-evdev/Makefile
In the output, you can see that curl returned the status code 60. According to man curl
60 Peer certificate cannot be authenticated with known CA certifiā
cates.
According to the setuptools page, you can instead use python ez_setup.py --insecure but obviously do that at your own risk. Alternatively you could do what the advanced instructions say and manually download the setuptools tarball, verify its md5 hash yourself, and install it using its setup.py .
A little background: I've been trying to make a restful server that can query and insert via the management API. After banging my head against the wall using node.js and javascript I switched over to python knowing it has more support.
Currently I am trying to follow the GA Tutorial: Hello Analytics API with a slight twist. I trigger the what was the main method in hello_analytics_api_v3.py when trying to access a particular end point on the server. This is only for testing. The method is called insertExperiment and attempts to insert an experiment into a private Google Analytics account.
However I'm always receiving the exception:
NotImplementedError('The gflags library must be installed to use tools.run(). Please install gflags or preferrably switch to using tools.run_flow().',)
Here is the full trace stack:
File "/0zzz/bottle.py", line 764, in _handle
return route.call(**args)
File "/0zzz/bottle.py", line 1575, in wrapper
rv = callback(*a, **ka)
File "server.py", line 39, in server_static
hello_analytics_api_v3.insertExperiment("xxxxxxx", "xxxxxxxxx", "xxxxxx", experiment_body)
File "/0zzz/hello_analytics_api_v3.py", line 11, in insertExperiment
service = hello_analytics_api_v3_auth.initialize_service()
File "/0zzz/hello_analytics_api_v3_auth.py", line 32, in
initialize_service
credentials = prepare_credentials()
File "/0zzz/hello_analytics_api_v3_auth.py", line 25, in
prepare_credentials
credentials = run(FLOW, storage)
File "/0zzz/oauth2client/tools.py", line 241, in run
'The gflags library must be installed to use tools.run(). '
NotImplementedError: The gflags library must be installed to use
tools.run(). Please install gflags or preferrably switch to using
tools.run_flow().
A few extra notes:
I have tried this exact same thing (invoking main on pinging the correct address) when copying the exact code from the Tutorial.
I have write access with the management API -- so that's not a problem here at all.
I thought there might be a namespace issue with one of my libraries (which also imports a run) but resolved this by renaming the other library.
GA Client Library is installed! as per the instructions on Hello Analytics API.
Thank you for any help you can provide!
I received the same error while running through a tutorial for google APIs called 'Google APIs Console Help'. The fix was simple in my case, just update the gflags library:
easy_install --upgrade python-gflags
You need to install gflags library.
$ wget https://python-gflags.googlecode.com/files/python-gflags-2.0.tar.gz
$ tar xfvz python-gflags-2.0.tar.gz ; cd python-gflags-2.0
$ python setup.py install
I installed the p4 library on my local archlinux machine and everything works smoothly.
I was now trying to do the same on a couple of virtual machines (with same OS also 64 bits) but can't get it running...
The installation goes well and doesn't complain, but when I try to import it I get:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "P4.py", line 312, in <module>
import P4API
ImportError: /usr/lib/python2.7/site-packages/P4API.so: undefined symbol: TLSv1_method
If I look in the symbols with
nm -A /usr/lib/python2.7/site-packages/P4API.so
I can see that in fact all the SSL-related symbols are undefined (while being defined on the working one), but why on earth?
I have openssl installed and Python is installed in exactly the same way, I can't find any other library that should be useful.
Any idea?
EDIT:
apparently the only difference is that in the wrong installation of P4 P4API.so is missing librt from the "ldd" output (and librt is actually there).
Not sure how it would relate to the TLS problem, and trying to reinstall glibc and then
p4python but no luck still..
Rebuilding the P4Python against the "rt" and "ssl" libraries fixes this.
Take the P4 API off the perforce site (e.g. for Linux take this: http://filehost.perforce.com/perforce/r13.2/bin.linux26x86_64/p4api.tgz)
Take the source code of P4Python off http://public.perforce.com/guest/robert_cowham/perforce/API/python/main/p4python.zip
tar xf the P4 API archive
Unzip the p4pthon archive
Edit setup.cfg to point to the P4API directory
Edit setup.py and go to line 120 and add "ssl" and "rt" so it looks like this
else: # Assume Linux
libraries = ["client", "rpc", "supp", "ssl", "rt"] # P4API libs
extra_compile_args = ["-DOS_LINUX", "-D%s" % p4_api_ver]
Do sudo python setup.py install
There were some excellent answers to this question already, however, they are now outdated.
I've been able to get the module installed, but "python manage.py runserver" fails with
iMac:myproject drhoden$ python manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x10496f0>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/validation.py", line 22, in get_validation_errors
from django.db import models, connection
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py", line 41, in <module>
backend = load_backend(settings.DATABASE_ENGINE)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py", line 17, in load_backend
return import_module('.base', 'django.db.backends.%s' % backend_name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 13, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dynamic module does not define init function (init_mysql)
^CiMac:segisys drhoden$
Likewise, from the python shell:
iMac:myproject drhoden$ python
Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-fat/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dynamic module does not define init function (init_mysql)
>>>
Using MySQL-python-1.2.3c1 with setuptools-0.6c11-py2.6.egg
Any help would be appreciated.
I have ultimately solved my own problem, with of course, the subconscious and conscious help from the many posts, blogs, and mail logs I've read. I would give links if I could remember.
In a nutshell, I reinstalled EVERYTHING using MacPorts.
After editing ~/.bash_profile and commenting out all the previous modifications to ${PATH}, I downloaded the dmg for Snow Leopard and ran through its installation.
Then opened the terminal and ran the self update.
sudo port selfupdate
sudo port install python26
That second part, installing Python 2.6, took forever. But when it completed it prompted me with the following:
To fully complete your installation and make python 2.6 the default, please run
sudo port install python_select
sudo python_select python26
I did both and they went quick.
I forgot to mention how handy 'port search ' command is. I searched for 'mysql' and similar to find the thing to type after 'install'. But I proceeded with reinstalling both the client and server for MySQL. Perhaps I did this in reverse order, but the end result worked fine.
sudo port install mysql5
...
---> Installing mysql5 #5.1.41_0
The MySQL client has been installed.
If you also want a MySQL server, install the mysql5-server port.
So naturally:
sudo port install mysql5-server
I love how the so many of the macports installations give you feedback as to what to do next. At the end of the server installation, it said the following:
******************************************************
* In order to setup the database, you might want to run
* sudo -u _mysql mysql_install_db5
* if this is a new install
******************************************************
It was a new install for me (didn't have any local schemas). For completeness, and for my own reference, here is the output of running that command:
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h iMac.local password 'new-password'
Alternatively you can run:
/opt/local/lib/mysql5/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!
The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/
Almost done. Earlier in my 'port search'ing I came across this interesting port:
py26-mysql #1.2.2 (python, devel, databases)
Python interface to mysql
With much, much hope that this would provide me with MySQLdb package, I installed it (and it did).
sudo port install py26-mysql
Afterwords I cranked up the python interpreter attempted to import MySQLdb, the very thing in my way all this time.
iMac:~ drhoden$ python
Python 2.6.4 (r264:75706, Dec 15 2009, 18:00:14)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet
>>>
A warning, but It worked!!
Just one more thing:
sudo port install py26-django
After all of this I was finally able to crank up my Django project and remotely connect to my company's MySQL server!! It may not have been necessary to reinstall Django using MacPorts, but I wasn't going to risk complications.
I wrote a blog post a few months ago following my successful installation of MySQL on Snow Leopard:
http://jboxer.com/2009/09/installing-mysql-on-snow-leopard/
If you follow those steps, it should (theoretically) fix your problem (which sounds like it's caused by a mix of 32-bit and 64-bit software).
By the way, I'm not trying to self-promote here; the text in the blog post is basically what I would've posted here, and I'm trying to apply DRY to more areas of my life :)
This happens when you have mixed 32 and 64bit software.
Basically, for Snow Leopard, you need to install MySQL 64bit package (which still is listed as 10.5, but that is no problem) , after that do an easy install of python-mysql again. All will work.