Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with install package #12

Open
lindbergh153 opened this issue May 13, 2021 · 21 comments
Open

problem with install package #12

lindbergh153 opened this issue May 13, 2021 · 21 comments

Comments

@lindbergh153
Copy link

Hello developer,
I try to install the package, yet some problems occurred when I run tests. All the feedback information is attached below. Besides, is there any technical documentation for this model?

#==================================================================================

(ForGIS) D:\tamoc-master>pytest -v --pyargs tamoc
================================================= test session starts =================================================
platform win32 -- Python 3.8.5, pytest-6.2.3, py-1.10.0, pluggy-0.13.1 -- D:\Program Files\MiniANACONDA\envs\ForGIS\python.exe
cachedir: .pytest_cache
rootdir: D:\tamoc-master
collected 6 items / 10 errors

======================================================= ERRORS ========================================================
_____________________________________ ERROR collecting tamoc/test/test_blowout.py _____________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_blowout.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init_.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_blowout.py:29: in
from tamoc import ambient, blowout
tamoc\blowout.py:36: in
from tamoc import seawater, ambient, dbm, dispersed_phases, bent_plume_model
tamoc\dbm.py:47: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
_______________________________________ ERROR collecting tamoc/test/test_bpm.py _______________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_bpm.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_bpm.py:33: in
from tamoc.test import test_sbm
tamoc\test\test_sbm.py:34: in
from tamoc import dbm
tamoc\dbm.py:47: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
_______________________________________ ERROR collecting tamoc/test/test_dbm.py _______________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_dbm.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_dbm.py:33: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
______________________________________ ERROR collecting tamoc/test/test_dbm_f.py ______________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_dbm_f.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_dbm_f.py:32: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
___________________________________ ERROR collecting tamoc/test/test_dbm_objects.py ___________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_dbm_objects.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_dbm_objects.py:20: in
from tamoc import dbm
tamoc\dbm.py:47: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
_____________________________________ ERROR collecting tamoc/test/test_params.py ______________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_params.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_params.py:32: in
from tamoc.test import test_sbm
tamoc\test\test_sbm.py:34: in
from tamoc import dbm
tamoc\dbm.py:47: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
_______________________________________ ERROR collecting tamoc/test/test_psm.py _______________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_psm.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_psm.py:35: in
from tamoc import ambient, blowout
tamoc\blowout.py:36: in
from tamoc import seawater, ambient, dbm, dispersed_phases, bent_plume_model
tamoc\dbm.py:47: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
_______________________________________ ERROR collecting tamoc/test/test_sbm.py _______________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_sbm.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_sbm.py:34: in
from tamoc import dbm
tamoc\dbm.py:47: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
_____________________________________ ERROR collecting tamoc/test/test_sintef.py ______________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_sintef.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_sintef.py:22: in
from tamoc import sintef
tamoc\sintef.py:17: in
from tamoc import psf
tamoc\psf.py:63: in
from tamoc import dbm
tamoc\dbm.py:47: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
_______________________________________ ERROR collecting tamoc/test/test_spm.py _______________________________________
ImportError while importing test module 'd:\tamoc-master\tamoc\test\test_spm.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
D:\Program Files\MiniANACONDA\envs\ForGIS\lib\importlib_init
.py:127: in import_module
return _bootstrap.gcd_import(name[level:], package, level)
tamoc\test\test_spm.py:35: in
from tamoc.test import test_sbm
tamoc\test\test_sbm.py:34: in
from tamoc import dbm
tamoc\dbm.py:47: in
from tamoc import dbm_f
E ImportError: cannot import name 'dbm_f' from 'tamoc' (d:\tamoc-master\tamoc_init
.py)
=============================================== short test summary info ===============================================
ERROR tamoc/test/test_blowout.py
ERROR tamoc/test/test_bpm.py
ERROR tamoc/test/test_dbm.py
ERROR tamoc/test/test_dbm_f.py
ERROR tamoc/test/test_dbm_objects.py
ERROR tamoc/test/test_params.py
ERROR tamoc/test/test_psm.py
ERROR tamoc/test/test_sbm.py
ERROR tamoc/test/test_sintef.py
ERROR tamoc/test/test_spm.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 10 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================= 10 errors in 1.04s ==================================================

@socolofs
Copy link
Owner

socolofs commented May 13, 2021 via email

@lindbergh153
Copy link
Author

lindbergh153 commented May 13, 2021 via email

@socolofs
Copy link
Owner

socolofs commented May 13, 2021 via email

@lindbergh153
Copy link
Author

lindbergh153 commented May 13, 2021 via email

@socolofs
Copy link
Owner

socolofs commented May 13, 2021 via email

@ChrisBarker-NOAA
Copy link
Collaborator

you can try the same thing within pycharm:

import tamoc
from tamoc import dam

The trick with pycharm or any IDE is to make sure it's running the "right" python -- that is, the one you installed tamoc into.

if you used a conda environment, make sure pyCharm is using that environment.

consult google to find out how :-)

@lindbergh153
Copy link
Author

lindbergh153 commented May 13, 2021 via email

@ChrisBarker-NOAA
Copy link
Collaborator

ChrisBarker-NOAA commented May 13, 2021

Please use the gutHub interface, rather than email for this -- we're getting a lot of weird formatting text!

But:

-->dam cannot be found.  ImportError: cannot import name 'dam' from 'tamoc' (d:\tamoc-master\tamoc\__init__.py)

this indicates that it is trying to import from the source code, rather than the installed version.

Make sure that you are running "outside" the tamoc source directory -- again, not sure how to do that with PyCharm, but there should be something about the "current working directory".

@lindbergh153
Copy link
Author

snapshot2021-05-13 171706
I ran this code from a different directory.

@ChrisBarker-NOAA
Copy link
Collaborator

did. you install with:

setup.py develop
or
pip install -e

That would put in a link to the source.

If so, and you can import tamoc, but not dam, then tamoc has not been built correctly. Try cleaning everytin out, building a gain, an see what / if any error messages you get.

BTW -- this all standard Python stuff -- not tamoc specific, so googling for general python package installation debugging hints should help.

@lindbergh153
Copy link
Author

Thank you so much, I'll clean this out and try it again.

ImportError: cannot import name 'dam' from 'tamoc' (D:\Program Files\MiniANACONDA\envs\ForGIS\lib\site-packages\tamoc-2.1.0-py3.8-win-amd64.egg\tamoc_init_.py)

@socolofs
Copy link
Owner

socolofs commented May 13, 2021 via email

@lindbergh153
Copy link
Author

Sorry Sir, I installed and uninstalled the package many times, it still doesn't work. Each step's result is presented in the attached pictures.
4
The procedure I followed as below:

  1. python setup.py install
    1
  2. python setup.py build
    2
  3. pytest -v --pyargs tamoc
    3

@socolofs
Copy link
Owner

socolofs commented May 14, 2021 via email

@socolofs
Copy link
Owner

socolofs commented May 14, 2021 via email

@lindbergh153
Copy link
Author

Hello Sir, thanks so much for your kind help and sorry for bothering you again. I followed this process and still have the same problem with import dbm_f. I asked my friends to install the package on their machine, one successfully passed the tests, yet one has the same problem with me. So I suspect something wrong with my computer... anyway, the error is enclosed in the text file.

error.txt

@ChrisBarker-NOAA
Copy link
Collaborator

These things are very hard to diagnose remotely, but I nticed this. At the top of your file, you have:

(base) PS C:\Users\1> activate tamoc3

which should activate the tamoc3 environment -- but that does not seem to have worked, as the prompts later on are:

(base) PS D:\tamoc-master> c:

the "(base)", I htink indicates that you are in the conda base environment.

So:

Newer versions of conda use:

conda activate tamoc3

However, if you are using base everywhere, it should still work.

It looks like the build was successful, so somehow it isn't getting installed properly, or it's getting installed into a different Python instance than you are using to run pytest, or other things. To debug, try this:

start up "plain" python:

> python

then do:

import sys
print(sys.path)

you will see all the paths that Python is using to find modules. as you did a "develop" install, the path to the tamoc source code should be there.

if not, those paths should give you a hint as to what's going on.

@lindbergh153
Copy link
Author

Hello Sir, thanks for your reply. I installed the model in environment tamoc3 and still have the same problem. I suspect this sentence that implies an issue:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
install information.docx
path.txt
These are c++ packages on my mechine.
c++

@lindbergh153
Copy link
Author

Hello developer,
Finally, the problem was fixed. I guess there is something wrong with my machine's compilation environment. I asked someone to develop the package on his computer, then transferred the complied files to me and passed the test. Anyway, thx for your kind help.

@ChrisBarker-NOAA
Copy link
Collaborator

Thanks for the report. @socolofs: This is a good motivator for making a conda packge -- I may give that a shot.

-CHB

@ASDolan
Copy link

ASDolan commented Jul 19, 2021

This is how I have installed it after many hours of trying. I'm no expert and it was not for me. Thanks to all that that have added to this.

  1. Install miniconda and set up a new Python environment called tamoc3. Install Python 3.8 or higher x64. You can find installer here: Https://ceprofs.civil.tamu.edu/ssocolofsky/downloads/Python/MiniConda.html

CMD
Change to miniconda install directory.
Run
conda update conda
conda create -n tamoc3
conda activate tamoc3
Conda deactivate

  1. Microsoft Visual C++ 14.0 or greater is required. Git it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/

  2. Perform the following commands to set up your Python environment:

CMD
Change to the TAMOC directory and run
Run
conda activate tamoc3
conda install numpy scipy matplotlib netCDF4 ipython pytest
conda install -c conda-forge fortran-compiler
Conda deactivate

  1. Clone the TAMOC repository to a new directory and open a miniconda shell in the new directory. Run the command:
    CMD
    Change to the TAMOC directory
    Run
    conda activate tamoc3
    python setup.py develop

  2. Change your directory to a directory outside of the tamoc repository. Then run:
    CMD
    Change to the TAMOC directory
    Run
    conda activate tamoc3
    pytest -v --pyargs tamoc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants