Closed smartlxy closed 3 years ago
Hi, thanks for reporting this. For complex packages, such as pandas and matplotlib, I would advise to add them in the setup.py
script, as:
from distutils.core import setup
import py2exe
setup(console=[{ "script": "matplotlib_test.py"}],
options={"py2exe": {
"packages": ['matplotlib']}})
Please, let me know if you can still reproduce this issue with this setup script.
Thanks for your answer ,the problem still exist. I tried many times ,find only pandas and matplotlib doesn't work,numpy is ok. My source file is as follows: import pandas as pd if name == 'main': print('hello,pyinstall') print(pd.dict) input('pause') Setup file is: from distutils.core import setup import py2exe setup(console=[{"script": "main.py"}], options={"py2exe": { "packages": ['numpy','pandas']}}) package version is: pandas:Version: 0.25.3 matplotlib Version: 3.0.2 pip:Version: 0.9.3.2 python:Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 windows version is:win10 professional . tank you very much ,waiting for your replay .
pandas
can be imported successfully with version 0.10.1.0. I would encourage you to try again with this new version. For the moment, I am closing this issue. Please feel free to reopen it if you experience the same problem again.
I'm experiencing the same issue, I have version 0.10.1.0 and am attempting to import pandas and numpy, my setup.py looking like: from distutils.core import setup import py2exe
setup(console=[{ "script": "filename.py"}], options={"py2exe": { "packages": ['pandas', 'numpy']}})
but when I attempt to run my python setup.py py2exe, I receive a huge block of file errors with "ValueError: attempted relative import beyond top-level package" at the bottom.
I am afraid I am unable to reproduce. The script that tests pandas
in the CI is also implcitly dependent on numpy
and does not show this error. I also attempted to run another script that explicitly depends on both packages on my PC and I am still not getting this error.
It would be really helpful if you could provide here also the content of the filename.py
packed code, some details on your configuration (Python version, OS version, pandas
version, numpy
version), and the full log that is produced when you run the python setup.py py2exe
command.
Thank you in advance for your time.
Full log of Errors: errors.txt filename: eDNA.txt Python version: 2.8.0 Windows 10 pandas version: 0.25.1 numpy version: 1.16.5
The version of Python and pandas
cannot be right. I guess that you have Python 3.8 but, for pandas
I actually have no idea given than now we are at version 1.1.4 (see https://pypi.org/project/pandas/#history). Could you double check your versions? Thanks
In any case, I am still unable to reproduce with your code. I would encourage you to upgrade your packages (pip install -U numpy pandas
). Here there are the package versions that I am using at the moment (Python 3.8)
numpy==1.19.4
pandas==1.1.4
Closing this again as I did not receive an update on the issue status and as I am still unable to reproduce. @raygunzapzap , I encourage you to try again with updated copies of numpy
and pandas
. Please feel free to reopen this issue if you experience the same problem again with up-to-date packages.
the problem is still not get solved. my computer environment detailed info is:
I download the py2exe source code, i find there is pandas and numpy test in ".\tests\functional" folder, i run it with the command : runner.bat pandas_test, unfortunately, same error appear as follow: F:\projects\pycharm\smartPython\documents\packages\py2exe\py2exe-master\tests>cd functional
F:\projects\pycharm\smartPython\documents\packages\py2exe\py2exe-master\tests\functional>runner.bat pandas_test
Requirement already satisfied: pandas in c:\program files (x86)\python36-32\lib\site-packages (from -r requirements.txt (line 1)) (1.1.4)
Requirement already satisfied: pytz>=2017.2 in c:\program files (x86)\python36-32\lib\site-packages (from pandas->-r requirements.txt (line 1)) (2019.3)
Requirement already satisfied: numpy>=1.15.4 in c:\program files (x86)\python36-32\lib\site-packages (from pandas->-r requirements.txt (line 1)) (1.19.4)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\program files (x86)\python36-32\lib\site-packages (from pandas->-r requirements.txt (line 1)) (2.8.1)
Requirement already satisfied: six>=1.5 in c:\program files (x86)\python36-32\lib\site-packages (from python-dateutil>=2.7.3->pandas->-r requirements.txt (line 1)) (1.13.0)
WARNING: You are using pip version 19.3.1; however, version 20.2.4 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
running py2exe
Traceback (most recent call last):
File "setup.py", line 6, in
further more,numpy also test failed,other package can success.
@smartlxy I am sorry that the issue is still affecting you but, I do not really know how to help you. As I am not able to reproduce the issue in my PC nor in CI, I think the problem is coming from something unique to your environment.
If possible, I would encourage you to try to package your code (or even repeat this test run) from an isolated/reproducible environment, such as Docker, or via any online CI system (GitHub Actions, AppVeyor, ...).
Tanks all the same,this issure really confused me a lot. I don't have any idea about "Docker, or via any online CI system". I will try it in a virtual system ,like VirtualBox.
There is a good new. I install a new windows10 64bit professional version in a virtual machine,then install python ,pandas ,py2exe.All my environment info as follows:
C:\Windows\system32>pip list Package Version
cachetools 4.1.1 future 0.18.2 numpy 1.19.4 pandas 1.1.4 pefile 2019.4.18 pip 20.3.1 py2exe 0.10.1.0 python-dateutil 2.8.1 pytz 2020.4 setuptools 39.0.1 six 1.15.0
C:\Windows\system32> C:\Windows\system32>python Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
In such an environment,I can successfully using py2exe building a exe package .
On my computer ,i check all the package,they are same with that in virtual machine ,but got the same error. My computer environment info as follows , C:\Users\smartlxy>pip list Package Version
adafruit-ampy 1.0.7 alabaster 0.7.12 alive-progress 1.6.1 altair 4.1.0 appdirs 1.4.4 astroid 2.3.3 attrs 19.3.0 autopep8 1.4.4 Babel 2.8.0 backcall 0.1.0 bcrypt 3.1.7 beautifulsoup4 4.8.2 bitarray 1.6.0 black 20.8b1 bleach 3.1.0 cachetools 4.1.1 certifi 2020.11.8 cffi 1.13.2 chardet 3.0.4 click 7.1.2 clipboard 0.0.4 colorama 0.3.9 coloredlogs 10.0 comtypes 1.1.7 cryptography 2.8 cx-Freeze 6.4 cycler 0.10.0 Cython 0.29.15 dacite 1.5.1 dataclasses 0.7 decorator 4.4.1 defusedxml 0.6.0 deprecation 2.1.0 distro 1.4.0 docutils 0.16 entrypoints 0.3 et-xmlfile 1.0.1 eyeD3 0.9.5 fake-useragent 0.1.11 Faker 4.1.0 filetype 1.0.7 fire 0.1.3 future 0.18.2 fuzzywuzzy 0.16.0 great-expectations 0.12.4 gTTS 2.2.1 humanfriendly 4.18 idna 2.8 imagesize 1.2.0 importlib-metadata 2.0.0 ipykernel 5.1.3 ipython 7.16.1 ipython-genutils 0.2.0 ipywidgets 7.5.1 isort 4.3.21 itchat 1.3.10 jdcal 1.4.1 jedi 0.15.1 jieba 0.42.1 Jinja2 2.10.3 joblib 0.15.1 jsonpatch 1.26 jsonpointer 2.0 jsonschema 3.2.0 jupyter 1.0.0 jupyter-client 5.3.4 jupyter-console 6.0.0 jupyter-core 4.6.1 kiwisolver 1.1.0 lazy-object-proxy 1.4.3 line-profiler 2.1.2 lml 0.0.9 lxml 4.5.0 Markdown 3.1.1 MarkupSafe 1.1.1 marshmallow 3.6.1 matplotlib 3.0.2 mccabe 0.6.1 mistune 0.8.4 more-itertools 8.0.2 MouseInfo 0.1.2 mpmath 1.1.0 mypy-extensions 0.4.3 Naked 0.1.31 nbconvert 5.6.1 nbformat 4.4.0 networkx 2.1 nltk 3.5 notebook 6.0.2 numexpr 2.7.1 numpy 1.19.4 opencv-python 4.2.0.34 openpyxl 3.0.3 packaging 20.1 pandas 1.1.4 pandasgui 0.2.7 pandocfilters 1.4.2 paramiko 2.4.2 parso 0.5.2 pathspec 0.8.0 pefile 2019.4.18 pickleshare 0.7.5 Pillow 6.2.1 pip 19.3.1 plotly 4.5.2 plumbum 1.6.8 prometheus-client 0.7.1 prompt-toolkit 2.0.9 psutil 5.7.0 py2exe 0.10.1.0 pyasn1 0.4.8 PyAutoGUI 0.9.48 pycodestyle 2.5.0 pycparser 2.19 PyCRC 1.21 pycryptodome 3.9.7 pyexcel 0.5.15 pyexcel-io 0.5.20 PyGetWindow 0.0.8 Pygments 2.5.2 pylint 2.3.1 PyMsgBox 1.0.7 PyNaCl 1.3.0 pynput 1.7.1 pyparsing 2.4.5 pypattyrn 1.2 PyPDF2 1.26.0 pyperclip 1.7.0 pypinyin 0.39.1 pypng 0.0.20 PyQRCode 1.2.1 PyQt5 5.15.0 PyQt5-sip 12.8.0 pyqtgraph 0.10.0 PyQtWebEngine 5.15.1 pyreadline 2.1 PyRect 0.1.4 pyrsistent 0.15.6 PyScreeze 0.1.25 pyserial 3.4 PySide2 5.14.0 PySimpleGUI 4.32.1 PySimpleGUIDesigner 0.1.4.6 PySnooper 0.4.2 python-dateutil 2.8.1 python-docx 0.8.10 python-dotenv 0.10.5 python-Levenshtein 0.12.0 pythonping 1.0.3 PyTweening 1.0.3 pytz 2020.4 pyverilog 1.2.0 PyVISA 1.9.0 pywin32 220 pywinpty 0.5.7 PyYAML 3.12 pyzmq 18.1.1 qtconsole 4.6.0 regex 2020.5.14 requests 2.22.0 retrying 1.3.3 rpyc 4.1.5 ruamel.yaml 0.16.12 ruamel.yaml.clib 0.2.2 scipy 1.2.0 selenium 3.141.0 Send2Trash 1.5.0 setuptools 39.0.1 shellescape 3.8.1 shiboken2 5.14.0 simplegeneric 0.8.1 six 1.15.0 snowballstemmer 2.0.0 soupsieve 1.9.5 spark-parser 1.8.9 speech 0.5.2 Sphinx 2.3.1 sphinxcontrib-applehelp 1.0.1 sphinxcontrib-devhelp 1.0.1 sphinxcontrib-htmlhelp 1.0.2 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.2 sphinxcontrib-serializinghtml 1.1.3 sympy 1.5 tables 3.6.1 tabula-py 2.0.4 termcolor 1.1.0 terminado 0.8.3 testpath 0.4.4 text-unidecode 1.3 texttable 1.6.2 thulac 0.2.1 tinydb 3.12.2 toml 0.10.1 toolz 0.10.0 tornado 6.0.3 tqdm 4.46.0 traitlets 4.3.3 treelib 1.5.1 typed-ast 1.4.0 typing-extensions 3.7.4.3 tzlocal 2.1 uncompyle 2.0.0 uncompyle6 3.6.4 urllib3 1.25.8 veriloggen 1.7.1 viztracer 0.7.3 wcwidth 0.1.7 webencodings 0.5.1 widgetsnbextension 3.5.1 WMI 1.4.9 wrapt 1.11.2 wxPython 4.0.6 xdis 4.2.2 xlrd 1.2.0 XlsxWriter 1.2.8 xlutils 2.0.0 xlwings 0.20.8 xlwt 1.3.0 you-get 0.4.1328 youtube-dl 2020.3.8 zipp 0.6.0 C:\Users\smartlxy>python Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
Help me check why it does not works, thanks very much.
@albertosottile I get the answer. the package nbformat will affect the result ,when nbformat==4.4.0, the error appear. when i upgrade nbformat version to 5.0.8,error disappear and every thing works well.
hello, i am a new programmer. i want to write a tools then share it with others。 the python version is: Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 py2exe version is: 0.9.3.2 when i write a program with pandas or matplotlib package,then package it using py2exe,i got a error like this: File "C:\Program Files (x86)\Python36-32\lib\site-packages\py2exe\mf3.py", line 215, in _resolve_name raise ValueError('attempted relative import beyond top-level package') ValueError: attempted relative import beyond top-level package.
my program is a test,no meaningfull functions in it,as follows: import matplotlib.pyplot as plt input('pause') my setup file's content is: from distutils.core import setup import py2exe setup(console=['demo_py2exe_python3.py']) If anyone could help me?thanks very much.