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

[Bug] Installing scons via 'pip install scons' doesn't work #146

Closed
Obijuan opened this issue Feb 18, 2018 · 4 comments
Closed

[Bug] Installing scons via 'pip install scons' doesn't work #146

Obijuan opened this issue Feb 18, 2018 · 4 comments
Labels

Comments

@Obijuan
Copy link
Member

Obijuan commented Feb 18, 2018

This is not an Apio bug but is reported here because is affecting the apio installation

This issue is comments in the scons user list: installing scons via pip install scons doesn't work

When trying to install apio with "sudo pip install apio" there is an strange message gotten: "error: option --single-version-externally-managed not recognized"

The problem is due to the scons package. It can be reproduced just by installling scons itself with:

 sudo pip install scons

In windows it seems to be fixed just by updating the setuptools and wheel

pip install -U setuptools
pip install -U wheel

(but more tests should be done)

The solution in linux is to install scons in a virtual environment. Then, if you install apio (inside or outside the virtualenv) it will work

  • Install virtualenv
sudo apt install virtualenv python3-virtualenv
  • Create a virtualenv with python3
virtualenv -p python3 test
  • Enter the virutalenv and activate it:
cd test
source bin/activate
  • Install scons
pip install scons

Now you can install apio inside the virtualenv, or outside

@Jesus89
Copy link
Member

Jesus89 commented Mar 3, 2018

Thanks for this contribution @Obijuan!

I have tested this steps. It works inside the virtualenv but then it is not fixed outside.

The bug is related to the detection of the libs in the main script. This libs are added to sys.path in order to import SCons.Script.

Since the virtualenv has only one version of Python, scons can detect and load the correct paths. Otherwise, if you have different versions of Python installed in your system, it can not detect the correct version for Python 3.5.

A solution is to setup the SCONS_LIB_DIR (which it is added to the libs) with the environment path of the current apio version. This is also good because apio will execute always the correct scons, in case there are multiple scons installed in the system.

Another solution is to execute the scons script with the correct python version.

@Jesus89
Copy link
Member

Jesus89 commented Mar 3, 2018

Since this issue is duplicated I can close it and continue there 😄

@Jesus89 Jesus89 closed this as completed Mar 3, 2018
@Obijuan
Copy link
Member Author

Obijuan commented Mar 11, 2018

@Jesus89 found this alternative solution:

platformio/platformio-core#279

It seems that installing scons with the following command does the trick

sudo pip install --egg scons

@physicst
Copy link

physicst commented May 2, 2019

Traceback (most recent call last):
File "/home/atif/rat/rat-pac-jsns2/bin/scons", line 63, in
import SCons.Script
File "/home/atif/rat/rat-pac-jsns2/python/SCons/init.py", line 43, in
import SCons.compat
File "/home/atif/rat/rat-pac-jsns2/python/SCons/compat/init.py", line 178, in
import shlex
File "/home/atif/python/python/Python-2.7.6/Lib/shlex.py", line 12, in
from collections import deque
File "/home/atif/python/python/Python-2.7.6/Lib/collections.py", line 8, in
from _collections import deque, defaultdict
ImportError: No module named _collections

i am trying to install RAT when i type command "scons" it gives this error
i dont know how to handle

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

No branches or pull requests

3 participants