I followed this to add zc.recipe.testrunner to my buildout. I can run buildout successfully but when I run bin/test, I get:
ImportError: No module named testrunner
I have zope.testrunner-4.0.4-py2.4.egg in
/usr/local/lib/python2.4/site-packages
I also pinned
zope.testrunner = 4.0.4
zc.recipe.testruner = 1.4.0
zc.recipe.egg = 1.3.2
When I ran buildout, I used -vvv and I got:
...
Installing 'zc.recipe.testrunner'.
We have the distribution that satisfies 'zc.recipe.testrunner==1.4.0'.
Egg from site-packages: z3c.recipe.scripts 1.0.1
Egg from site-packages: zope.testrunner 4.0.4
Egg from site-packages: zope.interface 3.8.0
Egg from site-packages: zope.exceptions 3.7.1
...
We have the distribution that satisfies 'zope.testrunner==4.0.4'.
Egg from site-packages: zope.testrunner 4.0.4
Adding required 'zope.interface'
required by zope.testrunner 4.0.4.
We have a develop egg: zope.interface 0.0
Adding required 'zope.exceptions'
required by zope.testrunner 4.0.4.
We have a develop egg: zope.exceptions 0.0
...
Why is it I get an ImportError? Is zope.testrunner not installed correctly?
Edit:
This is the relevant part in my buildout:
[buildout]
...
parts =
...
test
[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs =
my.product
This is the content in bin/test:
#!/usr/local/bin/python2.4 -S
import sys
sys.path[0:0] = [
'/home/jil/mySandbox/myTrunk/parts/test/site-packages',
]
import os
path = sys.path[0]
if os.environ.get('PYTHONPATH'):
path = os.pathsep.join([path, os.environ['PYTHONPATH']])
os.environ['BUILDOUT_ORIGINAL_PYTHONPATH'] = os.environ.get('PYTHONPATH', '')
os.environ['PYTHONPATH'] = path
import site # imports custom buildout-generated site.py
import os
sys.argv[0] = os.path.abspath(sys.argv[0])
os.chdir('/home/jil/mySandbox/myTrunk/parts/test/working-directory')
import zope.testrunner
if __name__ == '__main__':
zope.testrunner.run((['--auto-color', '--auto-progress']) + [
'--test-path', '/home/jil/mySandbox/myTrunk/src/my.product',
])
This is the error after running bin/test:
Traceback (most recent call last):
File "/home/jil/mySandbox/myTrunk/bin/test", line 20, in ?
import zope.testrunner
ImportError: No module named testrunner
I had the same problem. At least in my case, the cause was mixing dependencies already installed in 'site-packages' and dependencies installed by buildout in 'eggs': zope.deprecation and zope.interface were already in my 'site-packages' directory and thus were not re-installed by buildout. The path manipulation on the 'bin/test' executable seemed to import the 'zope' package from 'site-packages', without the 'testrunner' subpackage.
Try removing all zope.* packages from 'site-packages' and re-run buildout, or use 'include-site-packages = false' in the '[buildout]' section of your buildout.cfg. The first solution worked for me.
Related
I'm trying to install pl_cross repository using poetry. In the README it's indicated that it must be installed running python setup.py install. When I try to install the repo adding it to my pyproject.toml file:
[tool.poetry]
name = "iq_segmentator"
version = "0.1.0"
description = "Speed up Deep Learning semantic segmentation projects."
authors = ["Jeremiah Poveda Martínez <jere#qubiotech.com>"]
[tool.poetry.dependencies]
python = "3.9"
wandb = "0.12.18"
nibabel = "4.0.1"
torch = "1.11.0"
pytorch-lightning = "1.6.4"
torchmetrics = "0.9.1"
monai = "0.9.0"
hydra-core = "1.2.0"
black = "22.3.0"
pytest = "7.1.2"
numpy = "1.22.4"
matplotlib = "3.5.2"
pl_cross = {git = "https://github.com/SkafteNicki/pl_cross.git", branch="master"}
sphinx = {version = "5.0.2", optional = true}
sphinxcontrib-napoleon = {version = "0.7", optional = true}
sphinx-rtd-theme = {version = "1.0.0", optional = true}
[tool.poetry.scripts]
pl_cross = "pl_closs:setup"
[tool.poetry.extras]
docs = ["sphinx", "sphinx-rtd-theme", "sphinxcontrib-napoleon"]
[tool.poetry.dev-dependencies]
mlflow = "^1.26.1"
pydra = "^0.18"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
I get the following error:
Updating dependencies
Resolving dependencies... (4.8s)
PackageInfoError
Unable to determine package info for path: /tmp/pypoetry-git-pl_crossah48_3rm
Fallback egg_info generation failed.
Command ['/tmp/tmpfc8t0g_3/.venv/bin/python', 'setup.py', 'egg_info'] errored with the following return code 1, and output:
Traceback (most recent call last):
File "/tmp/pypoetry-git-pl_crossah48_3rm/setup.py", line 15, in <module>
import pl_cross
File "/tmp/pypoetry-git-pl_crossah48_3rm/pl_cross/__init__.py", line 40, in <module>
from .datamodule import BaseKFoldDataModule, KFoldDataModule
File "/tmp/pypoetry-git-pl_crossah48_3rm/pl_cross/datamodule.py", line 5, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
at ~/.poetry/lib/poetry/inspection/info.py:500 in _pep517_metadata
496│ try:
497│ venv.run_python("setup.py", "egg_info")
498│ return cls.from_metadata(path)
499│ except EnvCommandError as fbe:
→ 500│ raise PackageInfoError(
501│ path, "Fallback egg_info generation failed.", fbe
502│ )
503│ finally:
504│ os.chdir(cwd.as_posix())
NOTE: I have torch installed. Could someone point out what is causing the error? Is is possible to isntall packages this way with poetry? Is this documented?
Poetry is not able to parse the needed metadata (package name, version and dependencies) from the setup.py. This is why a wheel package needs to be build where Poetry can obtain these information.
Building the wheel is done in a clean, temporary environment and all build-dependencies mentioned in the pyproject.toml according to PEP-518 are installed into this.
The problem with pl_cross is, that within the setup.py pl_cross is imported, which in return imports other modules and dependencies, which are not installed in the build environment.
Please contact the maintainer of this project and ask them to refactor it, so that the unnecessary imports doesn't happen.
I am working on a project (CN_Analysis) for which I would like to create my own python package (cn_tools) using setuptools. My goal is to have it accessible everywhere in my project folder. However, when I try to import it from a subfolder (e.g. CN_Analysis/Notebooks), I get
(.virtualenvironment) ...:~/Workspace/CN_Analysis/Notebooks$ python3
import cn_tools
ModuleNotFoundError: No module named 'cn_tools'
The directory structure is as follows:
CN_Analysis
├──README.md\
├──requirements.txt\
├──.gitignore\
├──setup.py\
├──.virtualenvironment/\
├──Notebooks/\
├──Data/\
├──cn_tools/\
| ├──__init__.py\
| ├──my_tools.py
The contents of setup.py are:
from setuptools import setup, find_packages
setup(name = 'cn_tools',
version = '0.1',
description = 'This package contains helpful functions for the processing data obtained from Karambola.',
packages=find_packages(where='cn_tools'),
package_dir={'': 'cn_tools'})
Additional information:
The basic routine is
source .virtualenvironment/bin/activate
(.virtualenvironment) python3 setup.py develop
Results in
Installed /home/ansgar/Workspace/CN_Analysis/cn_tools\
Processing dependencies for cn-tools==0.1\
Finished processing dependencies for cn-tools==0.1
Check for python3
(.virtualenvironment) which python3
/home/my_name/Workspace/CN_Analysis/.virtualenvironment/bin/python3
And if I call sys.path from python after I navigated to a subfolder (e.g Notebooks/), it returns
['',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/my_name/Workspace/CN_Analysis/.virtualenvironment/lib/python3.8/site-packages',
'/home/my_name/Workspace/CN_Analysis/cn_tools']
Does someone know why I cannot import cn_tools?
It works if I just use
packages=find_packages()
instead of
packages=find_packages(where='cn_tools')
in the setup.py file.
I am trying to create a yocto recipe for scikit-learn package. It depends on scipy pacakge. I was able to successfully build the scipy package using : https://github.com/gpanders/meta-scipy.
When I run bitbake python3-scikit-learn, i am getting the below error:
ModuleNotFoundError: No module named 'scipy'
I am executing the commands in the below order.
Once I have cloned/copied the scipy recipes and the patches listed in the meta-scipy, i am running bitbake python3-scipy and the build was successful.
Then, I created a recipe file with the name python3-scikit-learn_0.23.2.bb and the contents are as below.
PYPI_PACKAGE = "scikit-learn"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=40ee42dc5a49f1617c5c78f16c50e065"
SRC_URI[sha256sum] = "20766f515e6cd6f954554387dfae705d93c7b544ec0e6c6a5d8e006f6f7ef480"
inherit pypi setuptools3
#DEPENDS = "${PYTHON_PN}-numpy-native ${PYTHON_PN}-numpy ${PYTHON_PN}-scipy ${PYTHON_PN}-joblib ${PYTHON_PN}"
DEPENDS = "${PYTHON_PN}-numpy-native ${PYTHON_PN}-numpy ${PYTHON_PN}-scipy ${PYTHON_PN}"
RDEPENDS_${PN} += "${PYTHON_PN}-numpy ${PYTHON_PN}-scipy"
When I run the bitbake python3-scikit-learn, i am getting this ModuleNotFoundError: No module named 'scipy'
Checked the path where the devshell python3 is looking (poky/build/tmp-glibc/work/aarch64-oe-linux/python3-scikit-learn/0.23.2-r0/recipe-sysroot-native/usr/lib/python3.8/site-packages), and i can only see the numpy package there, but scipy package is not there.
ls command output :
numpy
numpy-1.17.4-py3.8.egg-info
pkg_resources
__pycache__
README.txt
setuptools
setuptools-45.2.0-py3.8.egg-info
Can someone point me on how to include the python3-scipy package, so that it will be included/copied to the devshell. Or do I need to update/fix something else.
Appreciate any guidance on this.
you can also run:
bitbake -c devshell python3-scipy
and see exactly where the recipe is packaging everything into the rootfs. The rootfs is by default this:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/bitbake.conf#n457
IMAGE_ROOTFS = "${WORKDIR}/rootfs"
so check out what python3-scipy puts into ${WORKDIR}/rootfs (${WORKDIR} is where you get thrown into after you execute devshell, so just cd into rootfs from there).
If python3-scipy puts it into somewhere that is not on the PATH, you can add that to your path.
you can see how python3-scipy looks for libraries:
https://github.com/gpanders/meta-scipy/blob/1c07824202af668ef1539c3de392cf737c5ba3fd/recipes-devtools/python/python3-scipy_1.5.3.bb#L29
# Tell Numpy to look in target sysroot site-packages directory for libraries
LDFLAGS_append = " -L${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/lib"
I'm working on OS X Mavericks and want to use the NodeBox modules in Python scripts.
The post about how to install the modules for console is from 2009 and doesn't work anymore as this refers to version 1.9.x (current is 3.0.40). Also the SVN source isn't there anymore. The sources are available at GitHub.
By cloning the project and running:
ant run
all I get is a build of the desktop version.
How do I properly install and run the up to date NodeBox modules in Python scripts?
As said in the docs here in section 2. Installing the NodeBox module:
If you want to use NodeBox from the command line, you will have to install it. We currently recommend using Subversion to grab a copy:
svn co http://dev.nodebox.net/svn/nodebox/trunk/ nodebox
...
cd src
python setup.py install
we should be installing the usual way from the source, but as you say the procedure is rather outdated. The source apparently moved from SVN to GitHub at https://github.com/nodebox/nodebox-pyobjc as mentioned on the download page and the source package structure changed too.
Let's grab the source and try to install it:
$ git clone https://github.com/nodebox/nodebox-pyobjc.git
$ cd nodebox-pyobjc
$ python nodebox/setup.py install
Traceback (most recent call last):
File "nodebox/setup.py", line 17, in <module>
import nodebox
ImportError: No module named nodebox
So setup.py needs to import the nodebox package, let's add the project root dir to Python path, so that the nodebox package can be found and try again:
$ export PYTHONPATH=$PYTHONPATH:.
$ python nodebox/setup.py install
...
clang: error: no such file or directory: 'nodebox/ext/cGeo.c'
clang: error: no input files
error: command 'clang' failed with exit status 1
Now it turns out some lib paths in setup.py are wrong, no one probably used this for some time while the libs moved around, but we can fix it:
# ext_modules = [
# Extension('cGeo', ['nodebox/ext/cGeo.c']),
# Extension('cPathmatics', ['nodebox/ext/cPathmatics.c']),
# Extension('cPolymagic', ['nodebox/ext/gpc.c', 'nodebox/ext/cPolymagic.m'], extra_link_args=['-framework', 'AppKit', '-framework', 'Foundation'])
# ]
ext_modules = [
Extension('cGeo', ['libs/cGeo/cGeo.c']),
Extension('cPathmatics', ['libs/pathmatics/pathmatics.c']),
Extension('cPolymagic', ['libs/polymagic/gpc.c', 'libs/polymagic/polymagic.m'], extra_link_args=['-framework', 'AppKit', '-framework', 'Foundation'])
]
Try install again:
$ python nodebox/setup.py install
...
running install_egg_info
Writing <python>/lib/python2.7/site-packages/NodeBox-1.9.7rc2-py2.7.egg-info
$ pip list
...
NodeBox (1.9.7rc2)
...
Now the package installed successfully and we should be able to use it:
$ python
>>> import nodebox
>>> dir(nodebox)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__', 'get_version']
>>> nodebox.__version__
'1.9.7rc2'
Also, you may still need to manually install some of the dependencies for everything to work correctly, as noted in setup.py itself:
# We require some dependencies:
# - PyObjC
# - psyco
# - py2app
# - cPathMatics (included in the "libs" folder)
# - polymagic (included in the "libs" folder)
# - Numeric (included in the "libs" folder)
# - Numpy (installable using "easy_install numpy")
I already created a pull request with fixed setup.py lib paths, see here.
Tested on OS X Mavericks (System Version: OS X 10.9.3 (13D65), Kernel Version: Darwin 13.2.0) using Homebrew Python 2.7.6.
I'm trying to convert my Python project to a standalone executable, in order to run it on other servers that don't have Python installed.
Command used:
python setup.py build > build.log
When I try to run the resulting exe, it always spits out the following error message:
zipimport.ZipImportError: can't find module 'cx_Freeze__init__'
Fatal Python error: unable to locate initialization module
Current thread 0x00000b8c (most recent call first):
I've tried to define all the libraries I'm using throughout my project in the setup.py module, though this has made no difference.
I have also added the DLL files to include (described in the post cx-freeze doesn't find all dependencies).
The project consists of the following libraries (output of pip list):
cx-Freeze (4.3.2)
docopt (0.6.1)
pip (1.5.4)
psutil (2.0.0)
pywin32 (218)
requests (2.2.1)
setuptools (2.2)
virtualenv (1.11.4)
WMI (1.4.9)
Contents of setup.py:
include_files=[
(r'C:\Python34\Lib\site-packages\pywin32_system32\pywintypes34.dll', 'pywintypes34.dll'),
(r'C:\Python34\Lib\site-packages\pywin32_system32\pythoncom34.dll', 'pythoncom34.dll'),]
build_exe_options = dict(
packages=['os', 'concurrent.futures', 'datetime', 'docopt', 'email.mime.text', 'configparser', 'enum',
'json', 'logging', 'psutil', 'requests', 'smtplib', 'socket', 'subprocess', 'sys', 'threading', 'time',
'wmi', 'pythoncom'],
excludes=[],
include_files=include_files)
executable = Executable(
script = 'pyWatch.py',
copyDependentFiles = True,
base = 'Console')
setup( name= "pyWatch",
version= "0.1",
options= {"build_exe": build_exe_options},
executables= [executable])
cx_freeze's output (too large to paste here): http://pastebin.com/2c4hUSeD
All help would be greatly appreciated!
instead of cx_freeze which is last version updated on 2014
there is a module called pyinstaller which is last version update on 2016
pyinstaller
also easy to use just pyinstaller myscript.py and bam