Pytest Error in NUC Setup: Non-ASCII Character

Team, in the “pytest” step in the NUC setup, I am getting this error:

“Non-ASCII character ‘\xe2’ in file /var/panoptes/POCS/conftest.py on line 107, but no encoding declared”.

Does anyone know howto get past this error? I read the documentation at http://python.org/dev/peps/pep-0263/ but am not sure what to do next.

Thank you for any help!

Hi @clegrand,

What is the actual step you are running to get that error?

Hello @wtgee, this error is happening when running the “pytest” step. Thanks for any help!

@wtgee - here is the full text of the error message:

panoptes@pan005:/var/panoptes/POCS$ pytest
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/_pytest/config.py”, line 365, in _importconftest
mod = conftestpath.pyimport()
File “/usr/lib/python2.7/dist-packages/py/_path/local.py”, line 668, in pyimport
import(modname)
File “/var/panoptes/POCS/conftest.py”, line 106
SyntaxError: Non-ASCII character ‘\xe2’ in file /var/panoptes/POCS/conftest.py on line 107, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
ERROR: could not load /var/panoptes/POCS/conftest.py

panoptes@pan005:/var/panoptes/POCS$

Hi @clegrand. Somehow you are using a python2.7 instead of the python3.x that should be coming with the Anaconda install process.

I need to look at the doc and see how you got to this point so will have to do that in a bit, but that will point you vaguely in the right direction.

More later. Cheers!

Thanks, @wtgee! Is there a command that I can use to try the python install again for version 3.x? That might be an easy fix! (just to try it again).

After following the steps on the setup doc I receive the same error. I believe Ubuntu 18.xx comes with Python 3.6 already installed, and after trying sudo apt-get update and sudo apt-get install python3.6 it tells me I have the latest version. I have not installed Anaconda either. To the best of my understanding it seems that the code should be running under /usr/lib/python3.6/dist-packages/ instead of /usr/lib/python2.7/dist-packages. I’m not sure if we messed up somewhere in the installation process or something else is going on.

J

You should have this line in your $HOME/.profile file:

conda activate panoptes

This should set things up so that Python 3 and the required dependencies are “setup”. Note that conda is short for anaconda, a python distribution and package management system. An Anaconda environment includes a version of python and its set of dependencies or extra packages. The script ${POCS}/scripts/install/install-dependencies.sh should have created an environment called panoptes that includes Python 3. To test this, run this command:

conda env list

This should output a list of environments, such as:

# conda environments:
#
panoptes-env          *  /home/panoptes/anaconda3/envs/panoptes-env
py27                     /home/panoptes/anaconda3/envs/py27
root                     /home/panoptes/anaconda3

The * indicates the currently active environment.

If you do not have Anaconda you can still explicitly run any program using Python3.
I installed POCS on Ubuntu 18.04 and can run all tests successfully this way.

I had to install pytest first:

pip3 install pytest

Then go to cd ${POCS}

and run the whole test suite:

python3 setup.py test

To run a single test:

python3 -m pytest pocs/tests/test_messaging.py

Hope it helps

James and Team,

Thank you for the help. We tried both methods and have hit new errors. I cannot find anything relevant on Google or askubuntu to move forward.

I managed to get Anaconda installed and recognizing the “conda” commands. But the script to install the Panoptes env variables does not seem to have worked. The "conda env list’ shows only something called “base”. And in trying to re-run the POCS script to set up the panoptes env variable, I get the message “Please set Panoptes environment variables then re-run script”. I am not sure what to do from here.

On the first suggestion from jeremylan on the pytest issues, in running “python3 setup.py test”, I am getting Errno13: Permission denied 'pocs.egg-info/PKG-INFO".

On the single test command: python3 -m pytest pocs/tests/test_messaging.py, I got the error "No module named ‘astropy’; could not load /var/panoptes/POCS/conftest.py.

Unfortunately, I am too new to Linux to troubleshoot effectively when things go wrong, even with using Google and askubuntu. Any help or direction would be appreciated!

I’m perplexed. I’ll consult with Wilfred to see if we can understand what is going on.

FWIW, I’ve got an idea for a new approach to the setup: instead of asking you to create the panoptes user during the OS install, you’ll create your own user (e.g. “edwin”), and then once logged in as that user you’ll run a script that does all the other steps (or as many as I can automate), including creating the user panoptes and editing its .profile and .bashrc files. This will mean that folks not experienced with Ubuntu or Linux will not have to figure out as much… hopefully.