Can't create exe with pycharm as it complains pendulum locales - python-3.x

I have a GUI application that will not package to an exe with pyinstaller.
When I run pyinstaller main.py --onefile --windowed I get the following error.
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'pendulum.locales'
I updated pendulum from 1.4 to 2.0.5 and then the exe built fine. However this would not run. I reran pyinstaller without the --windowed flag and could then see the ORM I'm using (orator) is not compatible with > 1.4 pendulum and could not import Pendulum form pendulum.
from pendulum import Pendulum, Date
ImportError: cannot import name 'Pendulum' from 'pendulum' (C:\Users\Paul\PycharmProjects\JobsV10\venv\lib\site-packages\pendulum\__init__.py)
I have tried following posts that change the hooks in pyinstaller but none of these work.
https://github.com/pyinstaller/pyinstaller/issues/3528
I don't really want to remove orator as I use Laravel a lot and orator is close to the excellent Eloquent which I am familiar with. Is there a work around to get pyinstaller to work woth pendulum 1.4?
UPDATE
Changing
datas = collect_data_files("pendulum.locales", include_py_files=True)
in the Site Packages/Pyinstalller/hooks/hook-pendulum.py to
datas = collect_data_files("pendulum", include_py_files=True)
seems to have done the trick.
Not going to mark this as the answer yet as I'm not sure if this will cause issues down the line.

This has fixed my problem and has been in production for over 50 days with no issues so I am now going to mark it as answered. Although this fixed my issue, removing the '.locales' may break something in certain circumstances so always keep this in mind.

Related

Illegal Instruction 4 (Made a mess of python installation, no idea what I'm doing)

I am inexperienced with bash, python, and simply a lot of the basics/fundamentals some might take knowledge of for granted. I am using macOS 10.7.5. After installing numpy but getting error messages when importing in IDLE, I decided to reinstall python 3.7, but am getting several error messages now.
Some time ago, I installed python 3.7 from the python website, and it worked just fine. However, I had a great deal of trouble installing packages. The final straw was when I "successfully" installed numpy, but then I got a string of error messages when trying to import it in IDLE. I decided to try to re-install python, so I deleted python 3.7 and re-installed the same version from the same place.
However, when I tried typing "python3" in the Terminal, I got: "Segmentation Fault: 11". I researched it and understood that it had to do something with memory, so I must have uninstalled/installed wrong. However, I tried typing "python3" again, and got "Illegal Instruction: 4". After several tries, this is the only message I get anymore, and the segmentation fault does not appear.
I have no idea what I'm doing, and I don't know where to start. All I really know is that I've made a mess of the situation. I realize the solution might appear obvious, but I am completely inexperienced and in the dark right now. Thank you for reading this, I hope I can learn from you.
(Please ask for any and all information you might need, as I also don't know what exactly you might want to know.)
EDIT:
I realized when I re-installed Python, I had installed the macOS 10.9+ version. I uninstalled it and installed the correct version (10.6+). IDLE works and so does pip, but now I am getting the original error when I try to import numpy.
This is what I get:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/__init__.py", line 148, in <module>
from . import fft
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/__init__.py", line 6, in <module>
from .fftpack import *
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/fftpack.py", line 44, in <module>
from . import fftpack_lite as fftpack
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/fftpack_lite.cpython-37m-darwin.so, 2): Symbol not found: ___sincos_stret
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/fftpack_lite.cpython-37m-darwin.so
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/fft/fftpack_lite.cpython-37m-darwin.so```

How To Write Python 3 Import Statements When Running as Module and as Installed Program?

Problem
I find the importing process of Python is great in one context but often fails entirely in another. I have situation where I'm creating a program that can be run as a module or installed. It works one way (as a module), does not another (installed). It comes down to how I'm importing. What I don't know is how to fix it.
Note: This program will only ever run on Python 3.
Example of Problem
Here is the code repo that shows the problem: https://github.com/jeffnyman/pacumen
If you clone that, you can run the following in the project root:
python3 -m pacumen
And it works just fine.
Now, however, I want to install it. So from the project root:
pip3 install .
That works (via my setup.py) but then you should be able to run the program like this:
pacumen
The program runs but I get this error:
Traceback (most recent call last):
File "/usr/local/bin/pacumen", line 7, in <module>
from pacumen.__main__ import main
File "/usr/local/lib/python3.7/site-packages/pacumen/__main__.py", line 5, in <module>
from .mechanics import layout
ModuleNotFoundError: No module named 'pacumen.mechanics'
That's clearly due to my import statement.
But it's not clear what I can do to fix this. I'm finding most Python documentation to be singularly unhelpful in resolving import issues because what it tells me works in one context but not in another. I'm no doubt missing something.
What I've Tried
I have tried adding the following line to my __init__.py:
from .__main__ import *
This was from other comments on other questions. That, however, does not work. The same error is generated.
I tried changing my import in __main__.py to be this:
from pacumen.mechanics import layout
That was also a suggestion from another question. That, too, does not work. Same error.
My import can't be categorically wrong because it works while running as a module. So I'm not sure if my setup is being done inaccurately or if I need something else in __init__.py or if what I'm trying to do is in fact not something that you should be doing.
Well, of course, I think I found my answer after posting the above. I'm not sure if this is right but it seems to work so I'll document this as an answer in case someone else comes across this question.
What I had to do was add the following to my setup.py:
packages=['pacumen', 'pacumen.mechanics'],
Previously I only had this:
packages=['pacumen'],
I will clearly have to do that for every directory that I create.

python module not found error

This question has been asked a few times, but the remedy appears to complicated enough that I'm still searching for a user specific solution.
I recently installed Quandl module using pip command. Even after successful installation my python idle is still showing
Traceback (most recent call last):
File "F:\Python36\Machine Learning\01.py", line 3, in <module>
import Quandl
ModuleNotFoundError: No module named 'Quandl'
I have used import command in my code.
I am using python 3.6.1 version.
I am working on a windows 10 Desktop.
I have also tried re-installation of module.
You can better navigate to your python scripts folder and open a command window there and try pip3 install quandl .Hope this helps.

Python 3.3 + pygame installation

First, I am aware about the existance of a similar older thread, but honestly, I would not ask, if I found any help there.
Being a simple coding enthusiast, I want to playback media in using python. Since there seems to be no simple solution, a lot of people recommend pygame (or pyglet). So, using win 7 x64, I revert to 32bit Python 3.3.5 and download the presumably correct version of pygame from the super secret download site (pygame-1.9.2a0.win32-py3.3). Both installations work seemingly fine, pygame can locate python (path is set correctly), and finishes its install without issues, yet it seems not to install anything. I cannot import pygame, there are no installed libraries to be found. In pure frustration I tried different iterations of versions, python 2.7, x64, older pygame versions. Nothing worked. I suspect, there is something going on, that may not be connected to the pygame installation, but I don't know what.
import pygame
returns
Traceback (most recent call last):
File "C:/***/pygame_test.py", line 1, in <module>
import pygame
ImportError: No module named 'pygame'
Try using Python 3.2.3 instead of 3.3, along with Pygame for that version: that's what I did, and it works flawlessly on the same system as yours.
You should check up with your installation. Are you sure you installed properly. I have checked on 3.4/3.6/2.7 all works fine. Just install the correct binaries based on your system from http://www.lfd.uci.edu/~gohlke/pythonlibs/.
Download pygame using pip, to be sure that the module is placed in the correct path. Else, put the pygame folder in .\pythonX\Lib\site-packages\. Verify the folder is named pygame and not for example pygame-1.9.2a0.win32-py3.3.

python3 importing pygame results in PyCObject_AsVoidPtr

I have encountered difficulty putting pygame together with python3 on my MacBookPro.
I installed Python 3.3, and my MacOS is running version 10.7.5.
Then I downloaded pygamev1.9.1 source code, and followed instructions in http://programming.itcarlow.ie/PyGameInstall.pdf
Compilation and installation was smooth until I issued "import pygame" inside python3.
Then I encountered the following "PyCobJect_AsVoidPtr" error (further text following error message):
import pygame
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/init.py", line 95, in
from pygame.base import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so, 2): Symbol not found: _PyCObject_AsVoidPtr
Referenced from: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so
A search on google indicates this symbol has been removed since Python3.2:
http://mail.python.org/pipermail/python-dev/2011-March/108882.html
Can someone please give me some advice on how to get pygame working on Python3.3?
More so, whereas I am aware the pygame/python3 developers are busy with their work, but I would certainly appreciate it if someone can provide precompiled pygame binaries for python3. I have limited computer skills, and I just want to go ahead and learn Python3 and pygame, and this is seriously stunting my interest.
I notice that you were trying to compile from source, but builds on Python 3.3, to my knowledge, are not yet supported (as of January 2013). In fact, the only binaries I'm aware of for PyGame and Python 3.3 are unofficial builds and Windows only.
You should consider instead using a previous version of Python (e.g. Python 2.7.*), PyGame builds/binaries on which are well-supported. Any points on setting up should be directed to the pygame-users mailing list, if they weren't already.

Resources