I am using python; colab.
I tried to install package from" github.com/jleinonen/keras-fid" to import fid. And first time I used:
!pip install git+git://github.com/jleinonen/keras-fid.git
but I got error;
Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
So I used: !git clone
I install package from Github by using
!git clone https://github.com/jleinonen/keras-fid.git
than try to import module
However, I'm not sure but I think because package name contains "-", I got
SyntaxError: invalid syntax
How can I import the module from this package
The - is a red herring. The problem is that the Github repo cannot be pip installed because it does not contain a setup.py.
When you git cloned the code, you simply copied it to your environment. It's still not trivially installable ... though what you can do now is either add the cloned directory to your PYTHONPATH, or copy the file fid.py from inside it to somewhere which is already on your PYTHONPATH.
Quick demo:
bash$ python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fid'
bash$ git clone https://github.com/jleinonen/keras-fid.git
Cloning into 'keras-fid'...
remote: Enumerating objects: 12, done.
remote: Total 12 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (12/12), done.
Now, we have a local clone, but as you can see, it is not yet installed:
bash$ python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fid'
You can add the directory name (which does contain a hyphen, but that's unproblematic here) to your PYTHONPATH, and then it works ... except the code contains a syntax error.
bash$ PYTHONPATH=${PYTHONPATH+$PYTHONPATH:}`pwd`/keras-fid python -c "import fid"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/keras-fid/fid.py", line 134
def __init__(self, generator, image_range=,
^
I have no idea what the code is supposed to do, and I know nothing about Keras or Google Colab; but changing it to image_range, without an equals sign before the comma at least lets me bypass this error.
how to add the path to PYTHONPATH in google colab seems to have tips for how to do something similar inside Google Colab.
Related
I am trying to install pyscipopt. This should be done using pip install pyscipopt. The only catch is that pyscipopt requires the SCIP Optimization suite. Here is where I am having trouble. I wanted to make sure that my basic steps were correct.
The first way:
Following (https://github.com/SCIP-Interfaces/PySCIPOpt/blob/master/INSTALL.md)
Download SCIP optimization suite from https://www.scipopt.org/index.php#download
Then cd to my downloads folder. There, there is
scipoptsuite-7.0.1.tar
Run
tar xvfz scipoptsuite-7.0.1.tar
cd scipoptsuite-7.0.1
Then, following (https://scipopt.org/doc/html/CMAKE.php)
mkdir build
cd build
cmake ..
make
make check
make install
Alternatively, I also tried using make (https://scipopt.org/doc/html/MAKE.php)
I then either set export SCIPOPTDIR=<path_to_install_dir>, where <path_to_install_dir> is the path to scipoptsuite-7.0.1, in my downloads directory, or I added the scipoptsuite-7.0.1 directory to my $PATH. Either way, pip install pyscipopt worked.
However,
Ultimately I get (on one machine)
>>> import pyscipopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/usr/anaconda/lib/python2.7/site-packages/pyscipopt/__init__.py", line 10, in <module>
from pyscipopt.scip import Model
ImportError: dlopen(/Users/usr/anaconda/lib/python2.7/site-packages/pyscipopt/scip.so, 2): Library not loaded: libscip.7.0.dylib
Referenced from: /Users/usr/anaconda/lib/python2.7/site-packages/pyscipopt/scip.so
Reason: image not found
On another machine I get
>>> import pyscipopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/s/Library/Python/2.7/lib/python/site-packages/pyscipopt/__init__.py", line 10, in <module>
from pyscipopt.scip import Model
ImportError: dlopen(/Users/sam/Library/Python/2.7/lib/python/site-packages/pyscipopt/scip.so, 2): Library not loaded: libscip.7.0.dylib
Referenced from: /Users/s/Library/Python/2.7/lib/python/site-packages/pyscipopt/scip.so
Reason: unsafe use of relative rpath libscip.7.0.dylib in /Users/s/Library/Python/2.7/lib/python/site-packages/pyscipopt/scip.so with restricted binary
Is anyone able to install this software on a mac and give me a step by step guide, so at least I know I am not making any obvious mistakes? I guess there may be problems with my computers that can not be resolved, but I wanted to just make sure I had pieced together the instructions from various links correctly..
Another things I tried was just downloading the sh and running
sh scipopsuite-[VERSION].sh. This is considerably faster than make/cmake, and gives me what seems to be required in terms of lib, include and headers, but then when I try to pip install pyscipopt I usually get errors of the form scip/scip.h no such file or directory, command gcc failed as in (https://github.com/SCIP-Interfaces/PySCIPOpt/issues/54).
I am trying to generate a conda package (using conda-build) from some python source files and other DLL files. I first use a setup.py file to generate the python source code tar.gz file in the dist folder. All this works fine.
Then I am trying to create a conda tarball (tar.bz2) file by using conda-build. However it bombs out saying it cannot fine py2exe in setup.py. I had imported py2exe in the setup.py as an experiment at one point but have removed it since. The current setup.py does not have this import. So, I'm not sure why conda-build is still complaining about this. I even tried deleting all the files and directories that I think might be causing the problem and starting from scratch and it still complains. So, it's using a cached file from somewhere but I have no idea where. My bld.bat that conda-build uses is simply this:
%PYTHON% setup.py install
if errorlevel 1 exit 1
My recipe file is:
package:
name: projectname
version: 1.0.0
source:
url: ../dist/projectname-1.0.0.tar.gz
build:
number: 1
include_recipe: True
requirements:
build:
- python
run:
- python
Here is the relevant output of conda-build:
(%BUILD_PREFIX%) %SRC_DIR%>%BUILD_PREFIX%\python.exe setup.py install
Traceback (most recent call last): File "setup.py", line 2, in
import py2exe ModuleNotFoundError: No module named 'py2exe'
(%BUILD_PREFIX%) %SRC_DIR%>if errorlevel 1 exit 1 Traceback (most
recent call last): File
"d:\Continuum\anaconda3.5\Scripts\conda-build-script.py", line 10, in
sys.exit(main())
I was able to resolve the issue. For anyone else who may experience this issue, I did a global search for setup.py and found the offending file in the conda-bld folder that conda-build generates. I deleted the conda-bld and it resolved the issue.
I'm trying to pip install the python binding of MXNet library from source code:
https://mxnet.incubator.apache.org/install/ubuntu_setup.html#install-mxnet-for-python
After the main binary is built successfully using g++, there is no problem in installing its python binding in dev/editable mode:
pip install -e .
however when I try to deploy the full package (instead of just creating a symbolic link)
pip install .
I encounter the following error:
Processing ~/git-fork/mxnet/python
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-k3hfc693/setup.py", line 47, in <module>
LIB_PATH = libinfo['find_lib_path']()
File "/tmp/pip-req-build-k3hfc693/mxnet/libinfo.py", line 74, in find_lib_path
'List of candidates:\n' + str('\n'.join(dll_path)))
RuntimeError: Cannot find the MXNet library.
List of candidates:
/tmp/pip-req-build-k3hfc693/mxnet/libmxnet.so
/tmp/pip-req-build-k3hfc693/mxnet/../../lib/libmxnet.so
/tmp/pip-req-build-k3hfc693/mxnet/../../build/libmxnet.so
../../../libmxnet.so
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-k3hfc693/
It appears that pip didn't copy ../../lib/libmxnet.so into tmp since it is outside the python package directory. What should I do to instruct pip to copy that file (and if possible, everything under parent directory) when installing?
Where is your libmxnet.so located? It should be in the main-directory, so in your case: /git-fork/mxnet. Then the setup.py script should work out of the box. You could also manually set the path in setup.py, by adjusting the following line LIB_PATH = libinfo'find_lib_path'
I've been using django-numpy for some time now. But suddenly it gives an error, when I try to install it in a django project.
I've tried different approaches installing django-numpy - made a new venv - tried with another version og both django and django-numpy.
The error I get, when doing a pip install -r requirements.txt is:
Collecting django-numpy==1.0.1 (from -r requirements.txt (line 2))
Using cached https://files.pythonhosted.org/packages/35/b0/1f0be2e9c4df3b0736b09067dd041eb4475a6199b583428b241eb8576d7d/django-numpy-1.0.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-4qp99vp2/django-numpy/setup.py", line 6, in <module>
from pip.download import PipSession
ModuleNotFoundError: No module named 'pip.download'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
/tmp/pip-install-4qp99vp2/django-numpy/
I've tried installing different packages via requirements, with no problems. It's only django-numpy that gives an error?
I do not know if I should make an issue on django-numpy's github?
Has anyone seen this before? Below are the output logs that occur when I try to push to heroku ever since adding a new dependency, pysendy.
Note that pysendy requires the module 'requests' and thus I have also added requests to my requirements.txt. If you look at the top of the logs carefully you'll see that the requests module is downloaded & unpacked during the dyno startup, but pysendy doesn't see it. I even tried putting 'requests' at the top of the requirements.txt and nothing changed. Heroku rejects the app. I can get around this by manually importing pysendy into my project because it is small, but that sort of defeats the point of having dependencies.
My suspicion is that something about the request module dependency's installation isn't complete when pysendy tries to access the requests module.
Requirements.txt:
requests==2.2.1
Django==1.6.2
dj-database-url==0.3.0
dj-static==0.0.5
django-toolbelt==0.0.1
djangorestframework==2.3.13
gunicorn==18.0
psycopg2==2.5.2
pysendy==0.0.3
pystache==0.5.3
static==1.0.2
Output Logs:
-----> Python app detected
-----> Using Python runtime (python-3.4.0)
-----> Installing dependencies using Pip (1.5.4)
Downloading/unpacking requests==2.2.1 (from -r requirements.txt (line 1))
Downloading/unpacking pysendy==0.0.3 (from -r requirements.txt (line 11))
Downloading pysendy-0.0.3.tar.gz
Running setup.py (path:/tmp/pip_build_u37993/pysendy/setup.py) egg_info for package pysendy
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_u37993/pysendy/setup.py", line 5, in <module>
version = __import__('pysendy').__version__
File "/tmp/pip_build_u37993/pysendy/pysendy/__init__.py", line 2, in <module>
from .pysendy import *
File "/tmp/pip_build_u37993/pysendy/pysendy/pysendy.py", line 3, in <module>
import requests
ImportError: No module named 'requests'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_u37993/pysendy/setup.py", line 5, in <module>
version = __import__('pysendy').__version__
File "/tmp/pip_build_u37993/pysendy/pysendy/__init__.py", line 2, in <module>
from .pysendy import *
File "/tmp/pip_build_u37993/pysendy/pysendy/pysendy.py", line 3, in <module>
import requests
ImportError: No module named 'requests'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_u37993/pysendy
Storing debug log for failure in /app/.pip/pip.log
! Push rejected, failed to compile Python app
Seems like pysendy is trying to use requests during its installation, and despite having it in it's installation requirements (see https://github.com/thiagofa/pysendy/blob/master/setup.py) it's still not being installed. This is clearly an upstream bug since it reproduces on a clean virtual env.
A workaround could be to push an initial requirements.txt with pysendy commented out, let it complete, thus fully installing requests, and then push the full version again to Heroku.