py2exe strange missing modules - python

I think this is one of the many questions about missing modules and py2exe... anyway...
PylibUty is a local package located in C:\Dati\workspaces\PythonEclipse\APyLibUty\PyLibUty and referred in every .py file with:
import sys, os
sys.path.append(os.path.join(os.path.dirname("file"), '..'))
sys.path.append("C:/Dati/workspaces/PythonEclipse/APyLibUty")
from PyLibUty.pystr import randomString, insertStr
uuid is a Python package so I normally import it
_posixshmem I am not able to find what package I should install using pip/pipenv
resource: I installed both resource and pyresource using pip/pipenv bat nothing changed
What should I install or import to solve these problems?
This is the output produced running py2exe:

I did not find a solution to understand what modules I should add or install to clear the problems of py2exe, so I searched the web to find a different tool able to make exe files from Python sources. I found cx_freeze, actually it does not produce the errors I reported so at the moment I switched to cx_freeze. I will test it better but at the moment my problem is solved.

Related

can't find module, tried appending sys path and checked perms

new to python and trying to use plotly and I somehow broke something...
did pip install plotly, that worked.
was able to do "import plotly" in CLI, ok all good
then wrote a script and named it plotly.py
ran that and it can't find the module plotly
thinking the naming is causing a problem, I renamed my script to ptest.py, still can't find the module
read up here a bit... printing sys.path shows the directory plotly is in
checked the dir and made sure it is readable by all (it wasn't)
Still can't find the module
Added this to the script:
import sys
sys.path.append("path to module")
still can't find the module...
uninstall and reinstalled the module, no go.

How to properly import libtcod in PyCharm?

I'm trying to set up a roguelike Python project, but I can't seem to be able to import libtcod module into my project. This helloworld crashes, and the IDE keeps telling me that there is no module named libtcodpy.
import libtcodpy
def main():
print('Hello World!')
if __name__ == '__main__':
main()
What is the proper way to import modules into Python projects? I'm used to Java, so I was expecting something along the lines of Maven to manage the dependencies. There indeed seems to be something like that in PyCharm as well, this package manager for the venv, which from what I gather serves to isolate the project-specific stuff from the OS- or python-global stuff:
but libtcod simply isn't present in the rather exhaustive list of modules that appears after clicking on the "+" button, just some other module that has something to do with libtcod library (I guess?). Moreover, all the tutorials I found on setting libtcod up advise one to manually copy over files somewhere or run some command that I suppose does the importing somehow and other such solutions, all of which i tried and none of which worked. I don't want to pollute my project structure by using such hodgepodge ways of handling dependencies if I can at all avoid it.
Q: How do I get libtcod to work in my PyCharm project in the most clean and convention-abiding way possible?
Take a look at this github project called tcod: https://github.com/libtcod/python-tcod/blob/master/README.rst#installation
It's a python port of libtcod.
To install using pip, use the following command:
python -m pip install tcod
If you get the error "ImportError: DLL load failed: The specified module could not be found." when trying to import tcod/tdl then you may need the latest Microsoft Visual C runtime.
Blockquote

Python refuses to recognize library I am almost certain exists

I have no idea why this is so frustrating, but I have literally pulled out a few clumps of hair in rage because this just refuses to work and I honestly do not have the slighest clue on what to do. I am trying to use the winshell module for a quick python programming I am using. I am new to python and just started trying it today. I have tried to install the library manually, and through pip. pip claims the module is downloaded, and I can see it in the lib folder. No matter what I do I get this error when I try to run my code:
import winshell
ModuleNotFoundError: No module named 'winshell'
what on earth must I do to get this to work I am at my wits end here and I feel like I'm going to break something
You have to install the library with:
pip install winshell
I just tested with pip3 install winshell and it worked.
Python interpreter search for modules in the set of directories that you can see with:
import sys
print(sys.path)
I recommend you take a look to see if the directory where you are seeing the library in lib is include in that list.
Might be useful to you read: The Module Search Path

Get Python stack trace while using cx_freeze

I have a data acquisition program written in Python that I distribute to my collaboration as an executable (using cx_freeze), as I don't want to bother them with installing Python and installing all the software dependencies. The program has been working well for a year now. Recently, the program started to crash (crash, not give a scripting error, i.e., the Python virtual machine itself is crashing). So I would like to know what library is causing this problem. This problem is happening randomly, so it's difficult to systematically pinpoint the cause.
I learned about faulthandler, and I would like to use it with my cx_freeze, because I can't be sure the problem is happening due to cx_freeze itself or due to some other library.
The question: How can I produce a cx_freeze executable that will use faulthandler?
What I tried:
My current cx_freeze setup script is the following:
import sys
from cx_Freeze import setup, Executable
from GUI.Meta import *
target = Executable("Main.py",
#base = "Win32GUI",
icon = "GUI\\icon.ico",
compress=True,
targetName="Prog.exe")
setup(
name = "My Software",
version = SOFTWARE_VERSION,
description = "",
executables = [target])
I tried replacing my Executable part Main.py by Main.py -q -X faulthandler, but that didn't work. Importing faulthandler in my cx_freeze setup file with import faulthandler or from faulthandler import * didn't help.
Please advise.
Additional info: Dependencies that I'm using (in case you may know a possible cause of the problem): PySide, Sympy, Numpy, H5py, PySerial, Matplotlib
I learned that I could use procdump. It can be downloaded from here. It's a very simple program that can log stack trace. You can use it with:
C:\>procdump -ma -i c:\Dumps
and this will dump the stack trace of any program that crashes to that folder.

Trouble building Numpy 1.6.1 on Ubuntu 9.04--no __config__.py

I do research at my school by sshing into one of the machines in our lab. I do not have root access to these machines, so when I need to install new Python modules I typically build them in a local directory and modify my PYTHONPATH to point to this directory, rather than installing them to the standard directories (which I don't have permissions to). This has worked fine for several packages in the past, but with Numpy running
python setup.py install
seems to work, but there is no __config__.py file in the built directory. (The one it's supposed to import the module from) This causes the line in __init__.py
from numpy.__config__ import show as show_config
to raise an ImportError. I can't figure out why __config__.py isn't being generated as Numpy seems to assume that it will be. Running the build script seems to work; it completes with no troubling error messages. I've looked but can't find any answers to this. Please help.
I am using Python 2.6.2.
Well, I got numpy working by setting PYTHONPATH to point to the build/libXXX folder, but I was doing so to install scipy, which still demands some files as dependencies that don't exist in the either build directory I was trying. But that's another issue.

Categories

Resources