I'm trying to run my Python script form the Terminal (I write the scripts in Sublime Text2 and I use a Mac osx). This is by no means my first time running one as such but I keep on getting this error that I have never seen before, nor do I understand it:
dyld: Library not loaded: #rpath/Python
Referenced from: /Users/ronaldoisabeast/Library/Enthought/Canopy_64bit/User/bin/python
Reason: image not found
The only two commands I wrote were:
dhcp-18-111-122-239:~ ronaldoisabeast$ cd Desktop/
dhcp-18-111-122-239:Desktop ronaldoisabeast$ python dicegame.py
export PATH=/usr/bin:$PATH
Putting that line in your ~/.bash_profile (and restarting your terminal) might fix your issue
Related
The python programs on Windows have stopped executing scripts.
It will run python. For example, I can check the version and get the help text.
I've tried running it from "c:/User/.../python.exe", `py -3, etc.
I've also installed all Windows updates and re-installed python. (from version 3.8 to 3.10.7; same issue for both.)
Also, I've tried it from both power-shell and cmd.
I have tried a variety of scripts, but I have a test.py which just prints something.
Also, I've tried py -3 -c 'print("Hi")'. It does not work either.
All of these do not print any diagnostics. I simply get the shell prompt on the next line. I can also tell that the script is not even loaded. For example, if I give a filename that does not exist it does the same thing; no error message. The same occurs if I add a syntax error to the file.
I am seriously stumped. What could cause this?
I'm using pyinstaller to produce an exectuable for a python program. But, whenever I try to use a generated executable, I get a message window that reads "Failed to execute script ...".
The command I'm running is pyinstaller -w run.py. But, when run with the --debug option a different error is made apparent. "Failed to execute script pyiboot-1_bootstrap". After this error it kills the program.
I tried with the -F option and that did not change the outcome. All the files I created for the project are in the same directory. I did get warnings that dll's weren't being included but I resolved that.
Pyinstaller doesn't like the built in quit() function I was using.
Instead use sys.exit() to close the program.
See this question to see why sys.exit() is better practice for production code.
What I found useful was to make an exe of my .py script in console mode and then run it. For a very short period of time, I saw an error message in the console window. I had to screenshot it to read completely. So one of the imports was missing from the folder in which I had my script. I opened cmd from the location bar of that folder (by typing cmd there) and imported modules using pip install <module_name>.
Sorry for the long answer, I am a newbie.
I installed python 2.7.10 on my 1and1 linux hosting service about 8 months ago (using instructions from http://geeksta.net/geeklog/python-shared-hosting/) and everything was working fine (I had a daily cron job that would call my python script). But recently,my python script stopped working and it appears that the call to python itself is the culprit, rather than the python code. Whenever I type 'python' into the command line in the 1and1 unix ssh session now, i get the following error message
"-bash: /kunden/homepages/26/xxxxxxxxxx/htdocs/python27/bin/python: No
such file or directory"
It's been awhile since I installed things, but I don't believe I had this issue previously. I'm trying to figure out why it's not working and what I can do to get it fixed. It appears that calling python isn't working properly (which would affect my script as well).
Any help with getting this working would be greatly appreciated.
when you type python, system find it in /kunden/homepages/26/xxxxxxxxxx/htdocs/python27/bin/python, but there is no such a file in fact.
what you need to do is trying to locate your python binary executable file, and alias your python to your file
I ended up just reinstalling python 2.7 again and it works again. Not sure why it stopped working before.
Now I can type "python" in the command line and it starts the Python console.
I'm trying to run a python script from bamboo. I created a script task and wrote inline "python myFile.py". Should I be listing the full path for python?
I changed the working directory to the location of myFile.py so that is not a problem. Is there anything else I need to do within the configuration plan to properly run this script? It isn't running but I know it should be running because the script works fine from terminal on my local machine. Thanks
I run a lot of python tasks from bamboo, so it is possible. Using the Script task is generally painless...
You should be able to use your script task to run the commands directly and have stdout written to the logs. Since this is true, you can run:
'which python' -- Output the path of which python that is being ran.
'pip list' -- Output a list of which modules are installed with pip.
You should verify that the output from the above commands matches the output when ran from the server. I'm guessing they won't match up and once that is addressed, everything will work fine.
If not, comment back and we can look at a few other things.
For the future, there are a handful of different ways you can package things with python which could assist with this problem (e.g. automatically installing missing modules, etc).
You can also use the Script Task directly with an inline Python script to run your myFile.py:
/usr/bin/python <<EOF
print "Hello, World!"
EOF
Check this page for a more complex example:
https://www.langhornweb.com/display/BAT/Run+Python+script+as+a+Bamboo+task?desktop=true¯oName=seo-metadata
I am trying run a Fortran binary from within a Python script on a Mac. From the command line the Fortran binary works fine but when I run it with os.system or subprocess.open in Python then I get the following error:
dyld: Library not loaded: libimf.dylib
Referenced from: /Path/To/Binary
Reason: image not found
The Fortran binary is build with Intel Fortran. Any idea what goes wrong here?
EDIT:
I have these environmental variables set in my ~/.bash_profile which does not help:
export LD_LIBRARY_PATH="/opt/intel/compilers_and_libraries_2016.0.083/mac/compiler/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/intel/compilers_and_libraries_2016.1.111/mac/compiler/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/intel/compilers_and_libraries/mac/lib"
export DYLD_LIBRARY_PATH="/opt/intel/compilers_and_libraries_2016.0.083/mac/compiler/lib"
export DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/intel/compilers_and_libraries_2016.1.111/mac/compiler/lib"
export DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/intel/compilers_and_libraries/mac/lib"
I am running the python script from the terminal on my Mac. I tried printing from Python with
print os.environ['LD_LIBRARY_PATH']
print os.environ['DYLD_LIBRARY_PATH']
which both give the following error:
KeyError: 'DYLD_LIBRARY_PATH'
EDIT:
I tried running another binary with os.system in my Python code and that works fine.
I expect the problem is because there is no 'DYLD_LIBRARY_PATH' key in Python's os.environ dictionary; your profile setting of DYLD_LIBRARY_PATH seems fine, but Python isn't receiving it.
On my yosemite system, if I source the Intel-supplied compilervars.csh script to set DYLD_LIBRARY_PATH (resulting in a value of /opt/intel/compilers_and_libraries_2016.1.111/mac/compiler/lib:...) then the following succeeds for me
$ cat test.f90 && ifort test.f90 && python -c "import os; os.system('./a.out');"
print *, 'Hello World!'
end
Hello World!
(From bash you would presumably utilize the compilervars.sh script instead to do this.)
The problem is likely the new System Integrity Protection (SIP) built into Mac El Capitan. Basically, when you run a protected process, such as a python script, DYLD_LIBRARY_PATH is not passed to the script.
The best solution is recompiling your Fortran binaries in a manner that avoids the use of dynamic libraries. Alternatively, you can prevent this problem by disabling SIP (probably not recommended) as described here:
Macworld Article
You can find more information about this issue by searching "DYLD_LIBRARY_PATH SIP"