I'm using python 2.6, sqlalchemy 0.6 for a tiny desktop application. Also i'm using py2exe and sqlalchemy-migrate and i'm trying to integrate migrate inside the exe. In this way when the user starts the application the database gets automatically upgraded.
If i try to use migrate in my eclipse project it works well but i want to release the project itself in an exe using py2exe. Unfortunately when i start the exe i got the error:
Traceback (most recent call last):
File "sagra.py", line 7, in <module>
File "guiutil.pyc", line 3, in <module>
File "bo.pyc", line 4, in <module>
File "database.pyc", line 26, in <module>
File "<string>", line 2, in version_control
File "migrate\versioning\util\__init__.pyc", line 160, in with_engine
File "migrate\versioning\api.pyc", line 248, in version_control
File "migrate\versioning\schema.pyc", line 128, in create
File "migrate\versioning\repository.pyc", line 76, in __init__
File "migrate\versioning\repository.pyc", line 97, in verify
migrate.versioning.exceptions.InvalidRepositoryError: db_repository
but the directory db_repository and the migration scripts are correctly inside the "library.zip" used by py2exe to incorporate all the python resources used by my software.
It seems sqlalchemy-migrate doesn't search inside the zip for the directory of the repository.
Here the problem (repository.py):
def verify(cls, path):
"""
Ensure the target path is a valid repository.
:raises: :exc:`InvalidRepositoryError <migrate.versioning.exceptions.InvalidRepositoryError>`
"""
# Ensure the existence of required files
try:
cls.require_found(path)
cls.require_found(os.path.join(path, cls._config))
cls.require_found(os.path.join(path, cls._versions))
except exceptions.PathNotFoundError, e:
raise exceptions.InvalidRepositoryError(path)
How to read the repository from a zip ?
Is there anyone who have tried (and succeded) to use sqlalchemy-migrate inside the exe generated by py2exe ?
Thanks for any help
Related
my issue is that i've been trying to make an exe file with a .py that I created, but it doesn't work. I executed the converted .exe file from the console to see the log and I got this:
Traceback (most recent call last):
File "professors.py", line 10, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "docx2pdf\__init__.py", line 13, in <module>
File "importlib\metadata.py", line 551, in version
File "importlib\metadata.py", line 524, in distribution
File "importlib\metadata.py", line 187, in from_name
importlib.metadata.PackageNotFoundError: docx2pdf
[6940] Failed to execute script professors
I've been reading about the issue and it seems that pyinstaller doesn't recognize the docx2pdf import. I read in a website that I have to add it in a folder called site-packages, but it is supposed to have another folder inside called pyInstaller, which is not there. I also tried adding the folder manually but it still didn't work. I also tried with the --hidden-imports method but im not sure how to exactly use it.
I will have to apply this to other imports that I have also.
Any ideas? Thanks in advance!
I had a identical issue. I removed lines 7-13 from the docx2pdf module:
try:
# 3.8+
from importlib.metadata import version
except ImportError:
from importlib_metadata import version
__version__ = version(__package__)
and line 119...
print(__version__)
After that, it worked. Modifying the module probably isn't the best solution, and of course I'd recommend backing up the module before modifying it, but I hope it works for you too.
I have a Django project running under Django 1.8.4 that I'm trying to upgrade to latest version of Django. Since I was still using Python 2.7 on a Debian 8 server, I first upgraded my server to Debian 9 and then I upgraded my Django project's virtual environment to Python 3.5.3 (the default version of Python 3 on Debian 9).
After I rebuilt the virtual environment to use Python 3, I ran the command 2to3 -w . in my project's root folder. 2to3 found and fixed 62 problems without any difficulties. I also have 216 unit tests and only two of them failed under Python 3.5.
I then went to my Django website and the site appeared to be working except that the forms that contain pull-down elements show "SomeThingobject" instead of the values from the SomeThing table. I ran a few SQL queries directly against the database and confirmed that my SomeThing lookup table is populated.
Now I want to run a Django queryset command in the Python shell like the following to see why my pulldowns are not showing my column values:
queryset=SomeThing.objects.all()
However, if I activate my virtual environment and try to run the command ./manage.py shell, I get the following error:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/django/core/management/commands/shell.py", line 69, in handle
self.run_shell(shell=options['interface'])
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/django/core/management/commands/shell.py", line 58, in run_shell
return getattr(self, shell)()
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/django/core/management/commands/shell.py", line 41, in ipython
ip()
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/django/core/management/commands/shell.py", line 34, in _ipython
from IPython import start_ipython
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/IPython/__init__.py", line 48, in <module>
from .terminal.embed import embed
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/IPython/terminal/embed.py", line 19, in <module>
from IPython.terminal.ipapp import load_default_config
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/IPython/terminal/ipapp.py", line 30, in <module>
from IPython.core.magics import ScriptMagics
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/IPython/core/magics/__init__.py", line 22, in <module>
from .execution import ExecutionMagics
File "/srv/https/my_project.com/venvs/0bc664fa2a7b562d0b7e42a7acb3f095fe5df3cf/lib/python3.5/site-packages/IPython/core/magics/execution.py", line 21, in <module>
import cProfile as profile
File "/usr/lib/python3.5/cProfile.py", line 22, in <module>
run.__doc__ = _pyprofile.run.__doc__
AttributeError: module 'profile' has no attribute 'run'
Now I do have an application named 'profile' in my INSTALLED_APPS. If I try to open the Python shell on my production server which is still using Python 2.7, the shell executes without a problem. It's only having this problem with Python 3.5. What's interesting is that my Django 1.8/Python 2.7 project contains .pyc files but now under Python 3, they're replaced with __pycache__/<filename>.cpython-35.pyc files.
I read the Django document Porting to Python 3 but it doesn't seem to allude to this problem. What do I have to do to make this Django project operate properly under Python 3.5? Is there perhaps something new in Python 3.5 that is having a conflict with my profile application or is it something else?
After much digging around in the Python code I surmised that the problem was being caused by the fact that one of my applications inside the Django project was called "profile" and this was conflicting with a profile module in the newer version of cPython in Python 3.5. After I changed the name of the application to "userprofile" I could start the shell without any problems. These two articles help me change the app's name:
Stackoverflow: How to change the name of a Django app?
How to Change Name of Django Application
I'm a newbie to python and I'm trying to work on a web project with the pyramid framework. I use pycharm 4.0.4.
After creating a new pyramid project with pycharm and running setup.py develop, the project generates a ValueError when I try to run it as shown below:
C:\Users\Ovurevu\vir1\Scripts\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.0.4\helpers\pycharm\pycharm_load_entry_point.py" C:\Users\Ovurevu\Desktop\Python Scripts\Pyramid_one\development.ini
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.4\helpers\pycharm\pycharm_load_entry_point.py", line 8, in <module>
load_entry_point(dist, "console_scripts", name)()
File "C:\Users\Ovurevu\vir1\lib\site-packages\pyramid\scripts\pserve.py", line 58, in main
return command.run()
File "C:\Users\Ovurevu\vir1\lib\site-packages\pyramid\scripts\pserve.py", line 257, in run
vars = self.get_options()
File "C:\Users\Ovurevu\vir1\lib\site-packages\pyramid\scripts\pserve.py", line 197, in get_options
return parse_vars(restvars)
File "C:\Users\Ovurevu\vir1\lib\site-packages\pyramid\scripts\common.py", line 15, in parse_vars
% arg)
ValueError: Variable assignment 'Scripts\\Pyramid_one\\development.ini' invalid (no "=")
I have spent a lot of time trying to debug this issue.
What I'm I doing wrong?
I know this is an old question, but I just had this same error. I figured it out though. There shouldn't be anything wrong with the development.ini file.
Tested functionality via command line.
I believe it is because anything with a space is not parsed correctly. If you add " (quotes) around the path it will work.
Tested on
I'm using module transliterate.py from standard translit python libraries.
When I compile my GUI application, it raises the next error.
Traceback (most recent call last):
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\addobjectdialog", line 265, in OnTextName
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\core.utils", line 536, in translit
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.utils", line 41, in translit
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.utils", line 29, in ensure_autodiscover
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.discover", line 27, in autodiscover
WindowsError: [Error 3] : 'C:\\...\\...\\AppData\\Local\\Temp\\_MEI11122\\transliterate\\contrib\\languages/*.*'
How I understand, I have to place
that lib somewhere within my application. But I just compile one .exe file, so wouldn't like to keep yet one file with my exe.
BTW, app is ran under Win 7 / 32bit.
Thanks.
That may be one of those libraries that you have to include explicitly. I know I had to do that from time to time with py2exe. See the following docs for more information:
http://pythonhosted.org/PyInstaller/#options-for-finding-imported-modules-and-libraries
I just installed Pyevolve using easy_install and I am getting errors trying to run my first program. I first tried copy and pasting the source code of the first example but this is what I receive when I attempt to run it:
Traceback (most recent call last):
File "/home/corey/CTest/first_intro.py", line 3, in
from pyevolve import G1DList
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/init.py", line 15, in
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/Consts.py", line 240, in
import Selectors
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/Selectors.py", line 12, in
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/GPopulation.py", line 11, in
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/FunctionSlot.py", line 14, in
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/Util.py", line 20, in
AttributeError: fileno
I am running python 2.6 on Fedora 11 X86_64.
Edit: After looking into it more if I run python from the command line it works but it only fails when I'm running IDLE.
Have you tried to check out the Development version ? It's near of the RC1, so it is stable right now:
svn co https://pyevolve.svn.sourceforge.net/svnroot/pyevolve/trunk pyevolve
Your problem seems to be the paths, try uncompressing the "egg" file and put the "pyevolve" directory in the site-packages or inside your application directory.