For testing a Python library, I can do either
python setup.py install
python setup.py test
or
python setup.py build
python setup.py test
I prefer doing it the latter way. What things would I be missing to not go for the first?
EDIT : How can I test the installed code? The latter way is not doing that.
NOTE : I'm not choosing first because in that case I think something at permission level goes wrong over Travis-CI.
This is the error log
======================================================================
ERROR: Failure: OSError ([Errno 20] Not a directory: '/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/networkx_metis-1.0-py2.7-linux-x86_64.egg/networkx')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/nose/loader.py", line 414, in loadTestsFromName
addr.filename, addr.module)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
if (self.sameModule(old, filename)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/nose/importer.py", line 131, in sameModule
if _samefile(mod_path, new_path):
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/posixpath.py", line 162, in samefile
s1 = os.stat(f1)
OSError: [Errno 20] Not a directory: '/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/networkx_metis-1.0-py2.7-linux-x86_64.egg/networkx'
----------------------------------------------------------------------
Ran 1 test in 0.314s
FAILED (errors=1)
The command "python setup.py test" exited with 1
Can't be commented for Travis-CI, but there is actually no difference in the methods suggested.
python setup.py install is accompanied by python setup.py build internally. Just so as, a .egg file is created by install and it is copied to the system's dist-packages or site-packages.
Regarding testing, there is no such difference between the two methods.
Related
I'm trying to install pmdarima package in a conda env as it requires statsmodels <0.12 and I would also like to use statmodels latest release for this project. My understanding is limited, but I first tried
conda skeleton pypi pmdarima
This failed with the same AttributeError related to numpy disutils described below.
Similarly to the questioner in this question: Conda skeleton pypi: ModuleNotFoundError: No module named 'numpy' I was unable to get this to work either.
conda install -n _build numpy
I then tried the advice laid out in the above-linked SO question and ran:
conda skeleton pypi --extra-specs numpy pmdarima
This results in pretty long output but the key piece as far as I can tell is:
Applying patch: '/var/folders/7f/8d7rz34522gcq4z774n9v91r0000gn/T/tmp8tv1gdnxconda_skeleton_pmdarima-1.7.1.tar.gz/pypi-distutils.patch'
patching file core.py
Hunk #1 succeeded at 168 with fuzz 2 (offset 1 line).
Partial import of pmdarima during the build process.
Requirements: ['joblib>=0.11', 'Cython>=0.29,<0.29.18', 'numpy>=1.17.3', 'pandas>=0.19', 'scikit-learn>=0.22', 'scipy>=1.3.2', 'statsmodels>=0.11,<0.12', 'urllib3', 'setuptools<50.0.0']
Setting up with numpy.distutils.core
Traceback (most recent call last):
File "setup.py", line 324, in <module>
do_setup()
File "setup.py", line 320, in do_setup
setup(**metadata)
File "/opt/anaconda3/conda-bld/skeleton_1599410605346/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/lib/python3.7/site-packages/numpy/distutils/core.py", line 130, in setup
if dist.help or not _command_line_ok():
AttributeError: 'NoneType' object has no attribute 'help'
$PYTHONPATH = /var/folders/7f/8d7rz34522gcq4z774n9v91r0000gn/T/tmp8tv1gdnxconda_skeleton_pmdarima-1.7.1.tar.gz/pmdarima-1.7.1
Leaving build/test directories:
Work:
/opt/anaconda3/conda-bld/skeleton_1599410605346/work
Test:
/opt/anaconda3/conda-bld/skeleton_1599410605346/test_tmp
Leaving build/test environments:
Test:
source activate /opt/anaconda3/conda-bld/skeleton_1599410605346/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place
Build:
source activate /opt/anaconda3/conda-bld/skeleton_1599410605346/_build_env
Error: command failed: /opt/anaconda3/conda-bld/skeleton_1599410605346/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/bin/python setup.py install
Any ideas? Thank you so much in advance, very much appreciated!
Not sure what the proper resolution is for the NumPy-based build, but the setup.py does check for an sdist argument, which branches to use setuptools for the build instead of numpy. Hence, the following seems to avoid the code causing the issue:
conda skeleton pypi --setup-options sdist pmdarima
I suspect the downside to this workaround is that there is no Cython compilation done, but not totally sure.
You may want to file an issue on the pmdarima GitHub to see if any of the devs have ideas. Otherwise, it might just be more efficient to pip install the package in the environment you want it (as long as that environment is not base).
#merv thank you for your help! Interestingly, this works for the skeleton, but fails when running conda-build with the following (truncated until the errors) output:
0 location(s) to search for versions of sdist:
Given no hashes to check 0 links for project 'sdist': discarding no candidates
ERROR: Could not find a version that satisfies the requirement sdist (from versions: none)
ERROR: No matching distribution found for sdist
Exception information:
Traceback (most recent call last):
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
status = self.run(options, args)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
return func(self, options, args)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 325, in run
reqs, check_supported_wheels=not options.target_dir
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 339, in _get_abstract_dist_for
self._populate_link(req)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 305, in _populate_link
req.link = self._find_requirement_link(req)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 270, in _find_requirement_link
best_candidate = self.finder.find_requirement(req, upgrade)
File "$PREFIX/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 928, in find_requirement
req)
pip._internal.exceptions.DistributionNotFound: No matching distribution found for sdist
Removed build tracker: '/private/tmp/pip-req-tracker-umxriyi2'
Traceback (most recent call last):
File "/opt/anaconda3/bin/conda-build", line 11, in <module>
sys.exit(main())
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 474, in main
execute(sys.argv[1:])
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 465, in execute
verify=args.verify, variants=args.variants)
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/api.py", line 210, in build
notest=notest, variants=variants)
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/build.py", line 3036, in build_tree
notest=notest,
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/build.py", line 2155, in build
cwd=src_dir, stats=build_stats)
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/utils.py", line 407, in check_call_env
return _func_defaulting_env_to_os_environ('call', *popenargs, **kwargs)
File "/opt/anaconda3/lib/python3.7/site-packages/conda_build/utils.py", line 387, in _func_defaulting_env_to_os_environ
raise subprocess.CalledProcessError(proc.returncode, _args)
subprocess.CalledProcessError: Command '['/bin/bash', '-o', 'errexit', '/opt/anaconda3/conda-bld/pmdarima_1599500058832/work/conda_build.sh']' returned non-zero exit status 1.
I'll confess we're well above my head at this point, (do I need to edit the meta.yaml file somehow? Is that crazy?) but will try opening an issue as you suggested, once again really appreciate it.
At the moment I am trying to install theano on my ubuntu 16.04 system with cuda support. The installation process itself went well until I tried to test the installation:
python -c "import theano; theano.test()"
The last few lines of the output were:
======================================================================
ERROR: Failure: ImportError (No module named nose_parameterized)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/theano/tests/test_rop.py", line 16, in <module>
from theano.tests import unittest_tools as utt
File "/home/myUser/anaconda2/lib/python2.7/site-packages/theano/tests/unittest_tools.py", line 7, in <module>
from nose_parameterized import parameterized
ImportError: No module named nose_parameterized
----------------------------------------------------------------------
Ran 408 tests in 13.085s
FAILED (SKIP=26, errors=80)
These were preceded by approximately 20 blocks with what appears to be different tests failing on exactly the same top 3 lines in the stacktrace. The code where the final occurs looks like this (with added line numbers):
411. # FIXME: to support module.name names,
412. # do what resolve-name does and keep trying to
413. # import, popping tail of module into addr.call,
414. # until we either get an import or run out of
415. # module parts
416. try:
417. module = self.importer.importFromPath(
418. addr.filename, addr.module)
419. finally:
420. self.config.plugins.afterImport(
421. addr.filename, addr.module)
While searching for a solution I came across:
Error running nosetests
I tried the solution proposed there:
sudo pip install nose-parameterized
However this had no effect. Does anyone know what else could be causing this error?
edit: so I reinstalled theano to make the problem more reproducible. I installed theano using the instructions found here, so I used:
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git
sudo pip install Theano
Then I used:
nosetests theano
The last few lines of the output of this are almost the same as earlier:
======================================================================
ERROR: Failure: ImportError (No module named nose_parameterized)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/home/myUser/anaconda2/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/myUser/.local/lib/python2.7/site-packages/theano/tests/test_rop.py", line 16, in <module>
from theano.tests import unittest_tools as utt
File "/home/myUser/.local/lib/python2.7/site-packages/theano/tests/unittest_tools.py", line 7, in <module>
from nose_parameterized import parameterized
ImportError: No module named nose_parameterized
----------------------------------------------------------------------
Ran 457 tests in 160.608s
FAILED (SKIP=24, errors=95)
edit 2: I thought it might be a python-version issue. When I try:
python -V
I get:
Python 2.7.12 :: Anaconda 4.2.0 (64-bit)
And the following folders exist:
/usr/local/lib/python2.7/dist-packages/nose_parameterized
So, that shouldn't be a problem as far as I can see. However when I try:
python2.7 -c "import nose_parameterized"
I get:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named nose_parameterized
Found the problem, anaconda was looking in its own folder. So to solve, I did:
conda install nose-parameterized
The following works for me:
pip install nose-parameterized
My python version is 2.7. I tried to install pyjags using pip install pyjags but got such error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/dh/cyj9qhyj271945lvydyv5yr80000gn/T/pip-build-yuHm33/pyjags/setup.py", line 68, in <module>
add_jags(ext)
File "/private/var/folders/dh/cyj9qhyj271945lvydyv5yr80000gn/T/pip-build-yuHm33/pyjags/setup.py", line 46, in add_jags
version = add_pkg_config(ext, 'jags')
File "/private/var/folders/dh/cyj9qhyj271945lvydyv5yr80000gn/T/pip-build-yuHm33/pyjags/setup.py", line 34, in add_pkg_config
output = subprocess.check_output(args)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/dh/cyj9qhyj271945lvydyv5yr80000gn/T/pip-build-yuHm33/pyjags
I just deployed a python package and had same errors when I tried to install via pip. Turns out the main reasons was that the project artifacts (static files, etc) were not included in the MANIFEST file or it couldn't load a file path. I think you might want to consult the documentation here.
The line below was copied from the docs:
The setup.py script uses pkg-config to locate the JAGS library. If JAGS is installed in some non-standard location, then you may need to configure pkg-config to pick up correct metadata file. For example, if JAGS have been configured with --prefix=/opt/, then JAGS metadata file would be located in /opt/lib/pkgconfig/. This path can be included in pkg-config search path as follows:
export PKG_CONFIG_PATH=/opt/lib/pkgconfig/:$PKG_CONFIG_PATH
From your track trace, it seems like you failed to configure that.
pip is not a supported installation method. Read the installation instructions on the website enter link description here.
Error in command: python setup.py install
I am not getting the error. Please help
This is the error
>bash-4.2# python setup.py install
>ERROR:root:Error parsing
Traceback (most recent call last):
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/core.py", line 104, in pbr
attrs = util.cfg_to_args(path)
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/util.py", line 238, in cfg_to_args
>pbr.hooks.setup_hook(config)
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/hooks/__init__.py", line 27, in setup_hook
metadata_config.run()
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/hooks/base.py", line 29, in run
self.hook()
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/hooks/metadata.py", line 28, in hook
self.config['name'], self.config.get('version', None))
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/packaging.py", line 554, in get_version
raise Exception("Versioning for this project requires either an sdist"
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed? error in setup command:
Error parsing /sagar/nova/setup.cfg:
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed?
I think you haven't added git in PATH variable. I was facing similar issue myself while installing nova on Hyper V. Just updating the PATH variable did the trick
I have the academic distribution of EPD 7.1 for MacOS 10.6.x, which has pandas 0.3 version. The latest official version is 0.5.0 so I though I would upgrade to the latest.
Here is what I did:
saved the zip file of the source from here
executed sudo python setup.py install
ran tests by executing nosetests pandas
Please keep in mind I am a total newbie to python. Any insights on why my install failed would be greatly appreciated. Below is a snippet of the errors. The entire log can be found at Error log
Results:
Ran 1498 tests in 55.011s
FAILED (SKIP=4, errors=91, failures=14)
======================================================================
ERROR: test_generate (test_daterange.TestGeneration)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/core/tests/test_daterange.py", line 20, in test_generate
rng2 = list(generate_range(START, END, timeRule='WEEKDAY'))
TypeError: generate_range() got an unexpected keyword argument 'timeRule'
#wesm - thanks for your quick reply. Next time I will definitely use the mailing list. So I actually backtracked... installed the official 0.5.0 release and compiled from source. I received 3 errors (see below). I did not experience any problems running sudo python setup.py install
======================================================================
ERROR: testForSeries (pandas.stats.tests.test_ols.TestPanelOLS)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 472, in testForSeries
self.series_x, self.series_y)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 565, in checkForSeries
reference = ols(y=series_y, x=series_x, **kwds)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/interface.py", line 133, in ols
return klass(**kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/ols.py", line 36, in __init__
import scikits.statsmodels.api as sm
ImportError: No module named api
======================================================================
ERROR: testNonPooled (pandas.stats.tests.test_ols.TestPanelOLS)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 522, in testNonPooled
self.checkNonPooled(y=self.panel_y, x=self.panel_x)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 528, in checkNonPooled
result = ols(y=y, x=x, pool=False, **kwds)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/interface.py", line 133, in ols
return klass(**kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/plm.py", line 780, in __init__
nw_overlap=nw_overlap)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/interface.py", line 133, in ols
return klass(**kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/ols.py", line 36, in __init__
import scikits.statsmodels.api as sm
ImportError: No module named api
======================================================================
ERROR: test_auto_rolling_window_type (pandas.stats.tests.test_ols.TestPanelOLS)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 604, in test_auto_rolling_window_type
window_model = ols(y=y, x=data, window=20, min_periods=10)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/interface.py", line 133, in ols
return klass(**kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/ols.py", line 521, in __init__
OLS.__init__(self, y=y, x=x, **self._args)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/ols.py", line 36, in __init__
import scikits.statsmodels.api as sm
ImportError: No module named api
Best place to ask this question would be on the mailing list (luckily Google Alerts let me know about this right away!). It looks like your install failed and it's still using pandas 0.3.0. Were there any errors when you ran python setup.py install? You may have to upgrade your Cython installation if you're building from a git snapshot (sudo easy_install -U Cython). If that doesn't work, try nuking your existing pandas install:
sudo rm -rf /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas
and reinstalling. The tarball on PyPI includes pre-built Cython sources. If you're building from source anyway I recommend building from the head revision on git anyway. I'm days away from releasing pandas 0.6.0.
The problem was resolved by:
1) installing the pandas 0.6.0 release which Wes made available November 25/2011.
2) removing the existing scikits package, which is bundled with EPD 7.1 (version 0.2) and installing the latest release using 'easy_install -U scikits.statsmodels'.
The above were suggestions made by Wes and folks on the pystatsmodel mailing list (thank you to all).