I am trying to work on a lab machine using Python scripts that run fine on my local machine. The scripts were written for Python 2.7, and use the AARDVARK device library as an imported module.
The script runs on Windows' command shell, but fail to run on the installed Cygwin bash shell. The PYTHONPATH variable is defined correctly and similar to my local machine. When running, it complains that it cannot fin the AARDVARK module. So, following this question, I added the sys.path.append('/cygdrive/c/aardvark') command to my script.
Now, when I try running it, I get a pop-up message window saying Unable to bind Python API. API supports Python 2.3,2.4,2.5,2.6,2.7. Running python --version on the bash command line, I get 2.6.7.
What is this error message and how to eliminate it?
How can I make the script run and use the aardvark module?
Related
I am running an apple script that will run a python file upon the mac waking up from sleep. The applescript works and runs the python file. The problem is that if I try and run a python file that would uses modules then the file wont run. The error i get is saying that the computer cannot find the specific module.
in development i use a pipenv to install the modules.
If i could some how run a pipenv install required-modules either from the apple script or the python file i think this would solve my problem.
There is a thread on here that mentions trying to run AppleScript => bash => python file. However I have looked into it but my lack of knowledge is not enough to figure it out.
So my question is can a 'pipenv install required-modules' be run from an apple script or a python file?
I am running the python file from the following apple script:
set desktop_folder to "$HOME/Desktop"
do shell script "python " & desktop_folder & "/foobar/main.py"
I am looking to run my new Python script as a service. The problem is the users most definitely would not have Python installed. After doing research I found the two main options: nssm and the win32serviceutil code, but as far as I understand both require a Python installation on the PC, since you have to specify the path to your python.exe.
Is there any other way to make a Python script to run as soon as Windows is started and run in the background, which doesn't require an existing Python installation?
I have a python file in which I'm using the subprocess module to execute some command line scripts.
I'm using Git bash to run this python file. In the file, I execute the script:
KG_URL=http://127.0.0.1:8900
This script sets the variable successfully when I run it manually on the git bash command line.
But when I execute this using the python file, it gives me the following error:
'KG_URL' is not recognized as an internal or external command,operable program or batch file.
I tried digging deeper into this and I found out that executing the python file on git bash is the equivalent of running those scripts on the Windows cmd. When I tried running the set command without parameters (to get the current environment variables) on the Windows cmd, I found out that the variable KG_URL does not exist. But when I ran the same command on git bash, I can see that KG_URL exists.
Any idea why this discrepancy exists? And how can I solve this issue?
The reason why I'm executing these scripts in a Python file is because I need to convert it into an exe later. Assuming that all environments where I run this exe will have git bash installed, is there any way of ensuring that these scripts run only through git bash, and not the Windows cmd?
Normally when I wish to execute a python file I would change my directory in powershell and use the command,
python -i filename.py
I am currently using the library matplotlib for several scripts. Ive successfully launched them within Pycharm, however i also want to be able to run them within powershell or another console, unfortunately it is having troubles importing. Is there anything i can do?
I seem to have problem launching python from command line. I tried various things with no success.
Problem: When trying to run python from the command line, there is no response i.e. I do not get message about 'command not found' and console does not launch. Only option to open python console is to run C:\Python34\python.exe directly. Running using python command does not work even when in the python directory but python.exe launches. Issue with the launching this way is that python console is launched in new window. This whole problem is present only on one machine while on my other machine I am able to run python correctly and console launches in the command prompt window from which the python command was executed.
PATH is correctly set to
C:\Python34\;C:\Python34\Scripts;...
and where python correctly returns C:\Python34\python.exe. I verified that running other commands imported through PATH (such as javac) run correctly.
Things I tried:
Completely re-installing python both with x86 and x64 python installations with no success.
Copy installation from my second machine and manually set the path variables - again no success.
Can anyone hint how to resolve this behavior?
(Additional info: Win 8.1 x64, python 3.4.2)
Issue resolved. Since no feasible solution was found in 2 days, I decided to wipe all keys containing 'python' from registry as well as some files that were not parts of other programs. This resolved the issue after re-installing python.
If anyone finds the true cause of this misbehavior and other - less brutal - solution, please write it here for future reference.
Recent Python installer has option to add PATH.
If you didn't use it, you can register directory where python.exe is to PATH environment variable.
But I prefer py launcher. It may be installed via Python 3.3 or 3.4.
With it, you can start Python via py or py -3.4.
See https://docs.python.org/3/using/windows.html#python-launcher-for-windows