Ok I have a python3 environment, but I am lost!

I am stuck, who can help me?

Just google the question!. As the community is extremely active, most of the problems are already documented.

How do I solve an error?

A python error comes with a traceback, i.e. the list of calls that ended to an error. Read the traceback from the bottom. Using this example:

tests/test_guiform.py:5: in <module>
    from opentea.gui_forms.otinker import main_otinker
src/opentea/gui_forms/otinker.py:7: in <module>
    from opentea.gui_forms.root_widget import OTRoot
src/opentea/gui_forms/root_widget.py:70: in <module>
    from tiny_3d_engine import (Engine3D, load_file_as_scene)
E   ImportError: cannot import name 'load_file_as_scene' from 'tiny_3d_engine' (/usr/local/lib/python3.7/site-packages/tiny_3d_engine-0.1.0-py3.7.egg/tiny_3d_engine/__init__.py)

This is an Importation error (ImportError). The function load_file_as_scene was not found in the package tiny_3d_engine-0.1.0. The caller program opentea/gui_forms/root_widget.py isasking for something which does not exists in this distribution.

Nota: This illustrates a dependency error. Opentea should have forced a version requirement (tiny_3d_engine>=0) before relying on a new feature.

If you ask for help or report a bug, make sure you keep the traceback with you.

How to manage my python environment?

We encourage the use of pip. See the official documentation.

How can I know what is in my python environment?

Use pip list.

The output will look like:

tiny-3d-engine                0.1.0      /Users/dauptain/GITLAB/tiny_3d_engine/src     
tqdm                          4.45.0     
Tree                          0.2.4      
twine                         3.1.1      
typed-ast                     1.4.1      

You see in this list, three columns. In the first, the name of the packages installed. In the second, the version.

If a path is present in the third column (here tiny-3d-engine), the package is run from specific sources in your computer. . If the column is void, this package is installed in the site_packagesforlder of your python environment.

What is an installation in “Develop” mode, vs “Install” mode.?

The “install” mode is the most common situation. It is in very short a “read only mode”. You installed the package either via pip install from the Python Package Index, or via python setup.py install from the sources.

In “develop” mode, you are running a package from the sources. It is in very short a “read AND WRITE mode” This is useful if you are developing this package (editing the sources).

You can read the answer to this develop vs install question on stackoverflow.

How can I install something on an machine without internet?

If your machine is isolated from internet, but you can bring files on it, you can install packages from wheels. You need a similar machine, with:

  • a compatible processor.
  • a compatible linux distribution.
  • the same python version.

First download the wheel on the similar machine.

>mkdir h5py
> cd h5py
> pip download h5py
> cd ..
> ls -lrt h5py
total 17152
-rw-r--r-- 1 dauptain cfd  4012056 10 nov.  10:44 h5py-3.1.0-cp36-cp36m-manylinux1_x86_64.whl
-rw-r--r-- 1 dauptain cfd 13368977 10 nov.  10:44 numpy-1.19.4-cp36-cp36m-manylinux1_x86_64.whl
-rw-r--r-- 1 dauptain cfd     7573 10 nov.  10:44 cached_property-1.5.2-py2.py3-none-any.whl

Then make a archive:

> tree h5py
> tar -csv h5py.tar h5py

Upload the archive to your target, isolated, machine. Finally source your own virtual environment and install using pip/

(awesome_venv) > tar -cvf h5py.tar
(awesome_venv) > pip install h5py-3.1.0-cp36-cp36m-manylinux1_x86_64.whl --no-deps

Like this post? Share on: TwitterFacebookEmail

Antoine Dauptain is a research scientist focused on computer science and engineering topics for HPC.

Keep Reading





Stay in Touch