I am trying to install the python interface of the fsps program. However, when I run sudo python3 setup.py install I get the error:
Traceback (most recent call last):
File "/mnt/c/Users/Lea/Documents/HSCFA/python-fsps/fsps/__init__.py", line 26, in <module>
ev = os.environ["SPS_HOME"]
File "/usr/lib/python3.8/os.py", line 675, in __getitem__
raise KeyError(key) from None
KeyError: 'SPS_HOME'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "setup.py", line 87, in <module>
from fsps import __version__ # NOQA
File "/mnt/c/Users/Lea/Documents/HSCFA/python-fsps/fsps/__init__.py", line 28, in <module>
raise ImportError("You need to have the SPS_HOME environment variable")
ImportError: You need to have the SPS_HOME environment variable
However, I have already set the SPS_HOME variable in my ~./bashrc file, including the export statement. I have tried using the source ~/.bashrc command, restarting the shell, and also typing export SPS_HOME directly into the command line, but nothing fixes it. There was a similar question to this posted a while ago, where the poster's issue was due to the fact that they had not logged in as root when adding the environment variable to the .bashrc file, but they were running the installation command as root with sudo. I assume that they were able to fix this by logging in as root and re-adding the environment variable to .bashrc. However, this fix is not working for me, and I was wondering if anyone had any other ideas.I am using Ubuntu 20.04 and Windows 10.
Your problem here is that sudo, for security reasons, does not pass your environment variables to the command you execute. If you wish to do so, you may pass the -E flag to sudo, or specify it explicitly:
sudo SPS_HOME=$SPS_HOME python3 setup.py install
sudo is the culprit. Commands invoked through sudo don't inherit the environment from the caller's shell by default. sudo -E python3 setup.py install should disable this behavior.
Related
I can't properly install a Python 3.2 based virtual environment using virtualenvwrapper. I have hit a mystery wall and now I am looking for more options to solve my WHODUNNIT? predicament.
Some background
I first tried to install virtualenvwrapper using pip 1.5.6 from Python 2.7 (system's Python default). When I was trying to uninstall/upgrade my pip somehow I broke it. Now if I try:
$ pip
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 2816, in <module>
working_set.require(__requires__)
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 690, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 592, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (pip 7.1.2 (/usr/local/lib/python3.2/dist-packages), Requirement.parse('pip==1.5.6'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 2820, in <module>
parse_requirements(__requires__), Environment()
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==1.5.6
However, I managed to install PIP3.2.
$ pip3.2 --version
pip 7.1.2 from /usr/local/lib/python3.2/dist-packages (python 3.2)
So I proceeded to install virtualenvwrapper with no problem:
$ sudo pip3.2 install virtualenvwrapper
This is where Python 3.2 resides
$ whereis python3.2.3
whereis python3.2.3
python3.2: /usr/bin/python3.2 /etc/python3.2 /usr/lib/python3.2 /usr/bin/X11/python3.2 /usr/local/lib/python3.2 /usr/include/python3.2 /opt/Python-3.2/bin/python3.2 /usr/share/man/man1/python3.2.1.gz
This is my virtualenv version:
$ virtualenv --version
14.0.6
Error
Before making a virtualenv I modified my .bashrc
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/admin/workspace
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
After sourcing it (i.e. source ~/.bashrc) I just can't manage to start a virtualenv.
$ mkvirtualenv --python=/usr/bin/python3.2 venv
Running virtualenv with interpreter /usr/bin/python3.2
New python executable in /home/admin/.virtualenvs/venv/bin/python3.2
Also creating executable in /home/admin/.virtualenvs/venv/bin/python
/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py:87: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv.py", line 2304, in <module>
main()
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv.py", line 705, in main
symlink=options.symlink)
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv.py", line 924, in create_environment
download=download,
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv.py", line 843, in install_wheel
cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
File "/usr/lib/python3.2/pkgutil.py", line 573, in get_data
loader = get_loader(package)
File "/usr/lib/python3.2/pkgutil.py", line 461, in get_loader
return find_loader(fullname)
File "/usr/lib/python3.2/pkgutil.py", line 471, in find_loader
for importer in iter_importers(fullname):
File "/usr/lib/python3.2/pkgutil.py", line 427, in iter_importers
__import__(pkg)
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/__init__.py", line 15, in <module>
After the error if I type...
$ workon
$
Funny thing is the venv is created in .virtualenvs
Possible causes
Reading elsewhere in the web (I found just one person having a similar problem) it could be solved using a previous version of virtualenv (I tried that to no success), or maybe I'm using an incorrect combination of pip and/or virtualenv and/or virtualenvwrapper. Or perhaps it's my Python2.7 messing around in the background.
UPDATE: Setuptools
Or what about setuptools? Apparently it has to do. I was getting this error when trying with PIP 1.5.6
UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
ANOTHER UPDATE: Fixed the original pip
I managed to fix original pip using:
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
$ pip --version
pip 8.0.3 from /usr/local/lib/python2.7/dist-packages (python 2.7)
UPDATE: Virtualwrapper isn't!
In my own 'Whodunnit' saga I'd say virtualwrapper has nothing to do. Here:
$ virtualenv -p /usr/bin/python3.2 ~/.virtualenvs/venv32
Running virtualenv with interpreter /usr/bin/python3.2
New python executable in /home/admin/.virtualenvs/venv32/bin/python3.2
Also creating executable in /home/admin/.virtualenvs/venv32/bin/python
/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py:87: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
But problem still persists. What else could I try?
Thanks in advance!
You must use pip < 8 and virtualenv < 14 if you want to use Python 3.2. See also https://virtualenv.pypa.io/en/latest/changes.html#id7
Why do you need to use ancient Python 3.2? The best thing you can do would be to install and use the far superior Python >= 3.4 instead.
I have recently installed SimpleCV on Windows 10 from the superpack. Everything went well during the installation, and I was able to successfully run the first example problem in "Practical Computer Vision with SimpleCV" (good book, btw) from within IDLE. Here's the code:
from SimpleCV import Camera, Display, Image
cam = Camera()
display = Display()
img = cam.getImage()
img.save(display)
Simple enough, and it worked fine. Where I ran into problems was when I tried to start up the SimpleCV console. First of all, no link was created on the Windows desktop, and there was nothing for SimpleCV on the Start menu. So, I tried the other methods listed in the book. First, from the console, I tried to run it as a Python module:
C:\User> python -m SimpleCV.init
And what I got back was:
ERROR:
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\lib\site-packages\SimpleCV\__init__.py", line 18 in <module>
from SimpleCV.Shell import *
File "C:\Python27\;ib\site-packages\SimpleCV\Shell\__init__.py", line 1, in <module>
from Shell import *
File "C:\Python27\lib\site-packages\SimpleCV\Shell\Shell.py", line 54, in <module>
raise(e)
ImportError: No module named IPython
Next, I tried the listed alternative: just starting python and importing and executing the Shell. Entering:
>>> from SimpleCV import Shell
resulted in the same error as above.
I also tried installing ipython by running pip. But, it looks like pip didn't get installed either.
So, what environmental variable did the installation program not set correctly? Just so you know, I posted this same question on the SimpleCV site, but have not received a response as of yet.
--- 23 Dec 2015
Chipping away at this. Read the banner on setuputils install. Ran Python27\Scripts\easy_install.exe. Can now call pip. However, entering this at the command line:
C:\Users> pip install ipython
gives this error:
C:\Python27\lib\site--packages\pip-7.1.2-py2.7.egg\pip\_vendor\requests\packages\urllib3\util\ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cuase certain SSL connections to fail. For more information, see...
So, I'm making progress. Any suggestions?
Have you tried to install ipython from source code?
$ tar -xzf ipython.tar.gz
$ cd ipython
$ python setup.py install
See https://ipython.org/ipython-doc/3/install/install.html
There are a lot of requirements more. I recommend the SimpleCV's github repository instructions https://github.com/sightmachine/SimpleCV#windows-8
I used to install python (2.7.6) packages using sudo pip install [...] until I recently decided that this was a bad idea and I should use: pip install --user [...] instead.
Since I am using Mac OS X (10.10.3), my python modules had been installed into /Library/Python/2.7/site-packages. Now, with the --user option enabled, they are being installed into: /Users/USER/Library/Python/2.7/lib/python/site-packages
I have since moved all packages (including pip/setuptools) into this destination, adjusted my $PYTHONPATH and changed the file ownership to my local user. I expected that I would now be able to call pip install --user [..] and everything should go smoothly.
Unfortunately, this is not the case. For any pip install (or pip install --upgrade) command I receive the same error (below). The same is true when using a virtualenv - the same error shows up and I have no clue why.
However, everything does work "fine", when I use sudo pip install --user, which is why I assume that it is somehow related to a file-permission error I can not see. (It's not exactly fine, as the newly installed package will be in the right location, but all files are owned by root.)
Any idea what I am doing wrong or how to debug this?
pip install --upgrade --user tornado
Collecting tornado
Using cached tornado-4.1.tar.gz
Exception:
Traceback (most recent call last):
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/commands/install.py", line 280, in run
requirement_set.prepare_files(finder)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 317, in prepare_files
functools.partial(self._prepare_file, finder))
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 304, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 483, in _prepare_file
abstract_dist.prep_for_dist()
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_set.py", line 123, in prep_for_dist
self.req_to_install.run_egg_info()
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_install.py", line 368, in run_egg_info
self.setup_py, self.name,
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/pip/req/req_install.py", line 339, in setup_py
import setuptools # noqa
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extension import Extension
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/Users/USER/Library/Python/2.7/lib/python/site-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
I also checked the location of pkg_resources and deleted pkg_resources.pyc, which is located in /usr/local/lib/python2.7/site-packages for some reason, but it didn't change anything. (My local user also has full access rights in this location.)
[UPDATE:]
For some reason I was able to install virtualenv without root (pip install --user virtualenv), but all other packages I tried still fail. Also, if I switch to a new virtual environment, I still receive the same error. I am now thinking this is related to my $PYTHONPATH variable, which appears to not be updated for my virtualenv, but I haven't found the real solution, yet.
Alright, so I found the actual problem and solution. My $PYTHONPATH contained an invalid directory. I setup my $PYTHONPATH a long time ago and wrote it into a .bashrc (or more accurately .bash_profile) script.
pip was probably looking through all directories in $PYTHONPATH, although I don't know what it is doing in each of them that causes the above error, but removing the invalid directory fixed my problems.
I also now highly recommend to just use virtualenv instead of a static setup.
Setup:
Windows 7
Docker v1.6.0, installed as part of Boot2docker
Docker-compose v1.2.0
I installed docker-compose using pip:
pip install docker-compose
And it seemed to install successfully. However, when I try to run: docker-compose up in the directory in which I have my docker-compose.yml definition, I get the following exception:
Traceback (most recent call last):
File "c:\Python27\Scripts\docker-compose-script.py", line 9, in <module>
load_entry_point('docker-compose==1.2.0', 'console_scripts', 'docker-compose
')()
File "c:\Python27\lib\site-packages\pkg_resources.py", line 351, in load_entry
_point
return get_distribution(dist).load_entry_point(group, name)
File "c:\Python27\lib\site-packages\pkg_resources.py", line 2363, in load_entr
y_point
return ep.load()
File "c:\Python27\lib\site-packages\pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "c:\Python27\lib\site-packages\compose\cli\main.py", line 11, in <module>
import dockerpty
File "c:\Python27\lib\site-packages\dockerpty\__init__.py", line 17, in <modul
e>
from dockerpty.pty import PseudoTerminal
File "c:\Python27\lib\site-packages\dockerpty\pty.py", line 21, in <module>
import dockerpty.io as io
File "c:\Python27\lib\site-packages\dockerpty\io.py", line 18, in <module>
import fcntl
ImportError: No module named fcntl
I understand from different posts unrelated to docker that this error is thrown because fcntl is linux native and, obviously, my python windows distribution is missing it. However, the workarounds the people there specified don't necessarily apply to my personal case.
I also tried the steps here: https://github.com/docker/compose/releases
I downloaded the linux archive using curl (had no uname resolution) and gave execution right, but still:
$ docker-compose -version
./docker-compose: ./docker-compose: cannot execute binary file
Is anyone aware of any workarounds / actually functional ways of installing docker-compose on a Boot2docker VM?
You can run docker compose on boot2docker Windows.
You can install docker compose in a container directly in boot2docker and use it that way.
See "How to install docker-compose on Windows and issue 1085.
I've looked around on SO, and the answers I have found to my problem haven't allowed me to solve it yet.
I want to use isolated virtualenv environments, but for one reason or another, virtualenv keeps loading global site packages, when in django's shell...
I tried to clean up PATH variables, until only c:\Python26\Scripts and c:\Python26 remain. I then create my environment.
virtualenv --distribute --no-site-packages myproject
I then activate the virtualenv. PATH is now (irrelevant vars scrapped):
PATH=E:\Development\django_projects\myproject\Scripts;C:\Panda3D-1.7.0\python;C:\Panda3D-1.7.0\bin;c:\python26\Scripts;
PYTHONPATH=C:\Panda3D-1.7.0\
So far, so good. I launch python...
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
Let's just try a module I'm sure is in my c:\python site-packages directory.
>>> import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named BeautifulSoup
Yay! No global site packages! On to the next one then. From the command prompt, I type:
django-admin.py
And it works! But wait... I haven't installed Django yet. How is this possible?
After this, it gets even weirder... I first add these to virtualenv's activate.bat script so that Django can find my settings.
set PYTHONPATH=E:\Development\django_projects\myproject\
set DJANGO_SETTINGS_MODULE=settings.development
Now I launch django-admin.py shell and
In [1]: import BeautifulSoup
In [2]: BeautifulSoup.__file__
Out[2]: 'C:\\Python26\\lib\\site-packages\\BeautifulSoup.pyc'
How is this even possible?
Flash of insight
While typing this, I suddenly get it. .py is a file extension coupled with my c:\python26\python.exe executable, instead of the virtualenv one!
python manage.py
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manager
ImportError: No module named django.core.management
Heh. Anyone has any idea of how to couple the .py file extension to my virtualenv's python executable instead of the system defined python executable?
A little bit of extra .bat hackery can easily fix this. My standard additions to activate.bat are:
REM custom venv settings
set PYTHONPATH=%\VIRTUAL_ENV%;%\VIRTUAL_ENV%\conf;%\VIRTUAL_ENV%\apps
set DJANGO_SETTINGS_MODULE=settings
ftype Python.File=%VIRTUAL_ENV%\Scripts\python.exe %1 %*
and to deactivate.bat
REM restore ftype
ftype Python.File=C:\tools\Python27\python.exe %1 %*
You could make a .bat file and modify PATH and PYTHONPATH in there, and then run .py from that .bat file.
Something like this i think
set PATH=C:\Python26;
python myfile.py
Ofcourse, add anything else to your path that you want.
I had the same "Access denied" problems as Dan with m0nonoke's answer on my Windows 7 setup using cmd.exe.
But I found this work around using a replacement shell TCC/LE and a customised startup file...
Under working directory create subdirectory config. In this directory
create startup file for TCC/LE called tcstart.btm
#echo off
rem Override system python binding to handle virtualenvironments
set .py;.pyc=python.exe
Now create (copy) TCC/LE shortcut on desktop and rename it
appropriately. Open Properties for shortcut and add to Target
“C:\django\config\tcstart.btm”. You probably want to set Start in to
something useful, like C:\django
Solution found in this guide on installing Django and Windows.