I'm working on creating an app from Python code using py2app.
Everything goes well until I run setup.py, then at the very end of it running I get this message: "ValueError:
'/Users/(my_computer_name)/anaconda3/lib/libpython3.6.dylib' does not exist"
It turns out there is a file there, just named slightly different: It asks for 'libpython3.6.dylib' and there is a file named 'libpython3.6m.dylib'
Any insight would be greatly appreciated, thank you!
Anaconda Python binaries are build with multithread support and that means the library generated will have the form *m.dylib ( see this Google Groups link )
You could create a symlink and try to build using py2app (I had issues with that).
Alternatively this worked for me: I had an equivalent virtualenv setup (which uses a Python Framework and makes py2app locate the library differently) and was able to build the application on that one.
Related
I have a Windows machine in which some Python code works, but now needs to work on new machine.
I have installed the same Python version 3.6.5.
First issue was that when I run the code, it can not find a re.py library, which is in fact in Python's Lib folder. So I have added sys.path.append('C:\Python\Lib') and now it can find it.
But now I get the syntax error from that library, where I say import re, that lines throws an error regarding some line in re.py library. If I import getopt, I also get syntax error on some line.
How is that even possible? Syntax error in pythons Lib files which came with installation?
And the thing is that on machine 1 it works, same file contents, same python version. I am under impression that I have wrong in python.exe version for this version of libraries, but I have simply downloaded Windows installer and installed it.
I don't even know what to google for, does someone has any idea? I am importing re in WeblogicAuto.py on line 5.
D:\Jenkins\workspace\weblogic-full-deployment-copy\weblogic-deployment>MainAutoDeployment.py -f DEV -v 2.61.0.12
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
Problem invoking WLST - Traceback (innermost last):
File "D:\Jenkins\workspace\weblogic-full-deployment-copy\weblogic-deployment\WeblogicAuto.py", line 5, in ?
File "C:\Python\Lib\re.py", line 247
b"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890")
^
SyntaxError: invalid syntax
You are using WLST (WebLogic Scripting Tool).
WLST is very specific distribution of python:
it's jython
it roughly corresponds with python 2.7
And you trying to import libs from your CPython 3.6.5 distribution.
You need to:
remove your sys.path.append that you added earlier
check python libraries in jython library path. Which could be $HOME/.jython or WLST-specific path (look in WebLogic documentation)
OK many thanks to ya all, I've found the solution, it was about Jython libraries. I will try to elaborate a bit if someone stumbles upon this issue.
What I do here is that I deploy java modules to Oracle Weblogic application server. So this answer will also help someone trying to deploy to Weblogic from python.
From the start I was avoiding to install Webloglogic software on a machine from where I do the deploy (and that is a Jenkins slave which runs these python file, simple job).
I noticed that first machine (first Jenkins slave) has Weblogic installed, but I like to keep it minimal :)
What you do need is weblogic.jar and (not sure at this moment) wlfullclient.jar which is generated on Weblogic server (google how if needed or you may already have it).
The thing is that even though I have pure python code, when you call another python code with java weblogic.WLST pythonCode.py, it will be run with jython application! And it needs its libraries in its sys path.
In jython file I've added print(sys.path) then run in on both machines (slaves). I've noticed that path is different on those machines, even though if you type it in command prompt you get the same, but different then when Jenkins runs it.
So instead of looking how to fix those paths and copy files to them, I have created folders where it expects them, and copied them from first machine (easy fix, I may look into it later).
These are the sys.path and files that were needed, present on first machine:
['D:\\Jenkins\\weblogic\\Lib', '__classpath__', 'C:/bea10/wlserver_10.3/server/lib/weblogic.jar', 'C:/bea10/wlserver_10.3/common/wlst/modules/jython-modules.jar/Lib', 'C:/bea10/wlserver_10.3/common/wlst', 'C:/bea10/wlserver_10.3/common/wlst/lib', 'C:/bea10/wlserver_10.3/common/wlst/modules', '.']
This was sys.path on second machine, so I simply copied there:
['D:\\Jenkins\\weblogic\\Lib', '__classpath__', 'D:/Jenkins/server/lib/weblogic.jar', 'D:/Jenkins/common/wlst/modules/jython-modules.jar/Lib', 'D:/Jenkins/common/wlst', 'D:/Jenkins/common/wlst/lib', 'D:/Jenkins/common/wlst/modules', '.']
Note that jython-modules.jar is a file, so /Lib should be from that file if I get how java works.
Feel free to contact me for more details.
I'm using python 2.7.9 and encountered a problem when installing pygtk.
It displayed "Runtime error!...R6034 An application has made an attempt to load the C runtime library incorrectly" when installing numpy/scipy after pygtk being installed.
I tried to figure it out by searching it in stackoverflow and found two similar questions: Runtime error R6034 in embedded Python application and An application has made an attempt to load the C runtime library incorrectly.
So following the first one, I deleted the path corresponding to msvcr90.dll, however, it still cannot work. Then I chose to simply delete msvcr90.dll; at this time, this error wasn't presented when installing numpy/scipy, however, these two modules cannot work when simply typing "importing numpy/scipy".
I also renamed gtk-2.0 following the second one. Then numpy and scipy can be successfully installed. But it displayed "Error processing line 3 of C:\Python27\lib\site-packages\pygtk.pth" when installing matplotlib using pip.
I'm really confused about it. Can anybody provide some methods to fix it?
I've installed Python and PyGTK on 5+ machines, at least two of them brand new, clean builds of Win 7.
I've got the An application has made an attempt to load the C runtime library incorrectly error whenever I install a Python package as a windows installer (rather than using pip) on all these machines. It's annoying, but has never made a jot of difference, both Python and Gtk function correctly.
You've deleted msvcr90.dll, and that is why you get your Error processing line 3... If you look at this file, you'll see that line 3 is import runtime, and if you look further into the 'runtime' package, you'll see that this then tries to find the missing dll.
I think your best bet is to try to restore the missing file. If it's still in your recycle bin - great!
If not, the best thing to do is reinstall the Visual C++ runtime library
I made this video to show my way: https://www.youtube.com/watch?v=s6jhR1VBfeU. I use Anaconda to embedded Python in my C++ application. I simply changed "msvcr90.dll" to "msvcr90.dll_hihi" in 3 folders:
C:\Users\your user\Anaconda2\Library\bin, C:\Users\your user\Anaconda2 and C:\Program Files\Intel\iCLS Client (for x64)
I've run into a strange problem.
I built VTK with python wrappings on cent os 6.5.
On importing vtk it gives me PyUnicodeUCS2_* error. I checked python used for the build for unicode setting with sys.maxunicode. It is UCS4. I searched for this error and found that the error occurs when the VTK is built using UCS2 python. But, This is not the case in my case. What could be the reason for error?
The python that I'm using is picked from some other machine . If I run maxunicode on original previous machine it shows USC2. The same python (I copied the whole folder python2.6) on the other machine where I'm building VTK, shows maxunicode as UCS4. I think this has something to do with the problem.
Please help.
This error is caused by using an extension built by a UCS2-based Python interpreter with a UCS4-based interpreter (or vice-versus).
If you built it using the same Python interpreter then something is confusing in your build environment.
I tried to compile VTK with my python build several times. Checked the various paths in CMAKE to avoid conflict with system python. Still couldn't get rid of the error. Finally, I built the python with --enable-unicoe=ucs2. That solved the problem. Thanks for the help though.
New to programming (so please bear with me), but loving it so far. I coded a game using pygame and am having trouble compiling it as a stand-alone application using py2app. I'm using Macports Python 2.7, though I tried switching back to the default Mac installation (2.7) as well as the default 2.6 and still get this error during the py2app build:
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/mpmath/libmp/exec_py3.py", line 1
exec_ = exec
^
SyntaxError: invalid syntax
Exec_py3.py consists of all of one line:
exec_ = exec
Just for laughs I commented it out and the py2app proceeded further along in the build but then choked here:
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/macholib/MachO.py", line 304, in synchronize_size
raise ValueError("New Mach-O header is too large to relocate")
ValueError: New Mach-O header is too large to relocate
I don't know if the issues are related. Py2app is working fine for a couple little test scripts I wrote that don't use pygame. Any suggestions for what I can try next?
Thanks!
edit - I found a couple of links that may be related, but can't really understand what's going on in the conversation. Can anyone translate for a relative newby?
http://code.google.com/p/mpmath/issues/detail?id=204
https://bitbucket.org/ronaldoussoren/py2app/issue/93/mach-o-header-may-be-too-large-to-relocate
Well, I found a workaround in case anybody else runs into this. I uninstalled MacPorts and just used the Mac system Python (2.7). Everything then compiled fine. It was not enough just to use the port select command to switch to the system Python; I had to deinstall the whole thing.
I was writing a code which uses wxPython and comtypes. I have python 2.7 installed on my machine (Windows) along with wxPython, comtypes and py2exe. while trying to build it I got the following error:
error: MSVCP90.dll: No such file or directory
So, I did research I came to know about two solutions:
1. Copy Microsoft.VC90.CRT.manifest and msvcp90.dll to your machine and prepare your setup like as follows:
from distutils.core import setup
import py2exe
from glob import glob
data_files=[("Microsoft.VC90.CRT", glob(r'c:\shared_dlls*.*'))]
setup(data_files=data_files, console=['main.pyw'])
2. Use Python 2.5 along with wxPython, comtypes and py2exe
Now, I have following questions:
In first case:
a. Do I need to have Visual Studio license in order to use these files? or that can be used without any worries.
b. What if I compile it using aforementioned method? Does it still require MSVC90.dll on the user machine to execute? I think - No. Please correct me if I'm wrong. I want to remove any dependency and give user an exe which the user can directly execute without any dependency.
In Second case:
As I have Python_2.7 installed on my machine along with aforementioned modules. I would like to know can I install Python 2.5 on the same machine? Can they co-exist? If yes, do I need to install another copy of wxPython, comtypes and py2exe for this.
Please suggest me what is the best solution. How should I proceed? It's kind of blocking me.
Thanks in advance!
Python 2.5 and 2.7 (and all other versions of Python) co-exist very well. You may need to change your path to use the correct version of Python.
You will need to install the Python 2.5 builds of wxPython and py2exe. You will also need to install comtypes for Python 2.5. That installer will detect your Python installations by checking the registry.
I simply downloaded MSVCP90.dll file from here: http://www.dllme.com/dll/files/msvcp90_dll.html
and then pasted it into Python27\DLLs. It worked after that.
Did you try to install Visual C++ redistribuables?
I think you don't need a VS license for this.