Build numpy for python3 when python not installed in /usr - build

Fedora 18, x86_64.
Okay, so:
I have installed python3 in ~/utils/src/python3/Python-3.3.0/ so that it's available on NFS and I don't have to reinstall it on every machine in the lab.
I want to install numpy.
I got the source, it's in ~/utils/src/python3/numpy-1.7.0/ When I run python3 ./setup.py, I get:
file "~/utils/src/python3/Python-3.3.0/Lib/distutils/text_file.py", line 115, in open
self.file=io.open(self.filename, 'r', errors=self.errors)
FileNotFoundError: [Errno 2] No such file or directory:
'/usr/local/lib/python3.3/config-3.3m/Makefile'
Going up the stack, I get to sysconfig.py, line 435, which seems to generate the path name by calling get_makefile_filename, which is in sysconfig.py, line 251. It accesses globals (python_build, _sys_home, and a bunch of others), and I'm not sure how they're configured.
I tried passing --prefix=~/utils/src/python3/Python-3.3.0 to setup.py, but got nowhere. (And I'm not sure what exactly --prefix does anyways)
Has anyone had luck installing packages with nonstandard python3 installs?
Thanks,
Charles.

Okay, so here's the thing: distutils.sysconfig uses sys.executable, which is the location of the python executable. If this file is in the python build directory, then it will try to put everything in /lib. This was happening to me because I had a symlink from ~/utils/bin/python3 to ~/utils/src/python3/Python-3.3.0/python. sys.executable returned ~/utils/bin/python3, which was not in python's build directory.
Invoking the command as ~/utils/src/python3/Python-3.3.0/python setup.py got it to work.
I picked an arbitrary prefix (actually /dev/shm) and then copied everything that belonged in site-packages to ~/utils/src/python3/Python-3.3.0/Lib/site-packages/numpy, and it seems to work for now.

Related

PyMC installation error with pip

I am attempting to install PyMC using pip install pymc. I believe this command should install PyMC 2.3.6.
PyMC has a few dependencies, which I have in my PATH. I am running OSX 10.11.2 and my PATH includes Python 2.7.13, NumPy 1.12.0, Matplotlib 2.0.0, gcc, and gfortran.
Python (including pip) was installed using Homebrew. NumPy and Matplotlib were installed using pip. The gfortran compiler was downloaded and installed from the GCC Wiki for the purpose of this installation.
Executing pip install pymc yielded lots of output including the following lines.
Collecting pymc
Using cached pymc-2.3.6.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
running build_src
build_src
building extension "pymc.flib" sources
f2py options: ['skip:ppnd7']
f2py:> build/src.macosx-10.11-x86_64-2.7/pymc/flibmodule.c
creating build
creating build/src.macosx-10.11-x86_64-2.7
creating build/src.macosx-10.11-x86_64-2.7/pymc
IOError: [Errno 2] No such file or directory: 'skip:ppnd7'. Skipping file "skip:ppnd7".
updatevars:gradlike: attempt to change 'dimension(nx)' to 'dimension(na)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension(nx)' to 'dimension(nb)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension (nmu)' to 'dimension(nmu)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension (na)' to 'dimension(na)'. Ignoring.
rmbadname1: Replacing "index" with "index_bn".
Reading fortran codes...
Reading file 'pymc/flib.f' (format:fix,strict)
Line #34 in pymc/flib.f:" PARAMETER (infinity = 1.7976931348623157d308)"
get_parameters: got "unexpected EOF while parsing (<string>, line 0)" on ''
...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/2f/cr97n5v93mn04c3qbqd7r3q40000gn/T/pip-build-6Zmgcz/pymc/setup.py", line 124, in <module>
**(config_dict))
File "/usr/local/lib/python2.7/site-packages/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
...
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/2f/cr97n5v93mn04c3qbqd7r3q40000gn/T/pip-build-6Zmgcz/pymc/
As suggested in these two pip installation threads about egg_info errors [1, 2], I ran pip install —upgrade setuptools and pip install ez_setup. Once these items were installed I ran into the same types of errors pasted above.
As noted in other package installation threads, I am willing to use conda to install PyMC if I cannot resolve these issues. However, I'd like to investigate this installation issue first.
Would anyone happen to know what my issue is here? Might there be some steps I can take to successfully install PyMC using pip?
I had the same problem. I don't understand the root cause, but I fixed it by downgrading numpy to version 1.10.1: pip install numpy==1.10.1
I also met this problem while trying to install pymc from pip or source code, but I found a solution that might be useful.
The reason that causes the problem might be the file setup.py, in which the script check the compile env. I didn't read the code very carefully, but in the function build_ext() I think the codes first check whether some compile environments have already been installed into OS. If installed, the script will use them as defaults; if not, use ones in somewhere else (the comment says 'from netlib sources').
I infer the problem is caused by the compile environments that have already been installed in the OS, so I modify the file setup.py to skip this part of codes, and let the script use the netlib source. Then I run sudo python setup.py install. There are some error and warning messages, but the folder 'pymc' emerges in python library, and some simple test codes run successfully.

undefined symbol: OPENSSL_sk_num

I'm trying to renew Let's Encrypt certificate with Certbot. It stopped working and i don't know why. Here is the error:
ImportError: /root/.local/share/letsencrypt/local/lib/python2.7/site-packages/cryptography/
hazmat/bindings/_openssl.so: undefined symbol: OPENSSL_sk_num
I have newest OpenSSL version installed
OpenSSL 1.1.0d 26 Jan 2017
I tried debugging this problem by doing the following. First i just tried adding import OpenSSL in python console. It worked perfectly, no errors. But when i try
. ~/.local/share/letsencrypt/bin/activate
Then >>> import OpenSSl
I get error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/OpenSSL/rand.py", line 12, in <module>
from OpenSSL._util import (
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/OpenSSL/_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 14, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: /root/.local/share/letsencrypt/local/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so: undefined symbol: OPENSSL_sk_num
I tried removing the /root/.local/share/letsencrypt/ path then tried to run certbot-auto again. Still i get the same error. Is there anyone who faced this problem and know the solution? Please help me out here. Need to renew few certificates.
UPDATE:
I'v found the problem source that in /lib/x86_64-linux-gnu directory there is an old version of libssl.so.1.0.0 and it doesn't have OPENSSL_sk_num. When i try to replace with newer version libssl1.1 (it does have OPENSSL_sk_num) then i get an error that it requires OPENSSL_VERSION 1.0.1. Then after some struggle deleting libraries from /usr directories and local directories i get error ImportError: libssl.so.1.0.0: cannot open shared object file: No such file or directory. How can i change it so letsencrypt uses newer library?
SOLUTION
After some struggle. I just reinstalled openssl version 1.1.0c. Copied letsencrypt library from another project and it worked. I think some upgrade ruined it. So i suggest everyone when you are running letsencrypt just use --no-self-upgrade option.
SOLUTION UPDATE
After encountered this problem one more time i decided to resolve it the correct way. So basically you need to recompile openssl 1.1.0c with command:
./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)' and make
Copy the compiled libcrypto.so.1.1 and libssl.so.1.1 to /usr/lib/x86_64-linux-gnu
Then you need to redo or just modify libcrypto and libssl symlinks.
By being in /usr/lib/x86_64-linux-gnu folder enter commands ln -s libssl.so.1.1 libssl and ln -s libcrypto.so.1.1 libcrypto.
Then enter following commands:
cd ~/.local/share/letsencrypt/bin/
./pip uninstall cryptography pyopenssl -y
./pip install --upgrade pip
rm -rf ~/.cache/
./pip install cryptography pyopenssl
And your'e done, everything should work correctly.
It looks like in version 1.1.0f of openssl the symbol OPENSSL_sk_num has moved to libcrypto.a. The build of python 3 didn't seem to link that in, hence the missing symbol. However, I was mistaken. When the file Modules/Setup.dist is modified to pick up your own version of openssl, you need to copy it to Modules/Setup, otherwise it will use the already installed ssl.
I also had the undefined symbol: OPENSSL_sk_num error after compiling openssl myself.
I could solve the problem by removing the openssl directory in~/.local/share which was created erlier and starting over. It has to be some caching and/or wrong library path issue.
I met this error when install Python3.6.2 on Centos 7 ,it has been intalled openssl 1.0.1e,and I download openssl 1.1.0.e. after next steps it works correctly.
cd ${openssl_src_path}
in my case ${openssl_src_path} is '/usr/local/server/openssl-1.1.0e'
./configure --prefix=/usr/local --openssldir=/usr/local/openssl
make
make test
make install
after OpenSSL installed correctly, install Python3.6.2
cd ${python_src_path}/Modules
modify 'Setup' file ,change log :
SSL=/usr/local/openssl
_ssl _ssl.c \
-DUSE_SSL -I/usr/local/openssl/include -I/usr/local/openssl/include/openssl \
-L/usr/local/openssl/lib -lssl -lcryptoere
'SSL=/usr/local/openssl' is value of install OpenSSL parameter '--openssldir' .and make sure DUSE_SSL directory exist.
cd ${python_src_path}
./configure
make
make install
hope it help.

Django Install Wierdness - Mac OSX 10.8.5 and Macport Python 2.7.6 - Django/Python/Unix beginner

I've found a lot of posts on Macports/Django install issues but none seem to quite address my situation.
Installed Django using Macports from the command line using
sudo port install py27-django
This seemed to work fine. I opened up IDLE and was able to import django. The following bit of code
import django
from django.core import management
print django.VERSION
returns
(1, 5, 1, 'final', 0)
Which I take to mean I have the final version of Django 1.5.1 installed. So, all seems to be well.
However, now I switch over to my Django tutorial to get learning and I am asked to type this into the command line to confirm that Django is installed:
python -c "import django; print(django.get_version())"
and get the following error:
> File "<string>", line 1, in <module> ImportError: No module named
> django
Some other bits of data. Here's my $PATH:
/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Finally, the command
django-admin.py startproject mysite
returns
-bash: django-admin.py: command not found
But the command
django-admin-2.7.py startproject mysite
works (creates a new directory called mysite in the working directory). I read somehwere that Macports renames the django-admin file.
I've only been working with Unix for a few weeks so this is a bit confusing. It seems like I have Django on my system, but perhaps the python I am trying to access from my command line is a different python from that which Macports uses.
Any help appreciated!
Dennis
You will need to set your PYTHONPATH environment variable from your terminal to reference your django install. IDLE probably did this for you, but in another shell you'll need to set it. You can set it in your terminal permanently by setting it in ~/.bashrc or ~/.bash_profile (or whatever your terminal shell is).
Your PATH starts with /Library/Frameworks/Python.framework/Versions/2.7/bin so when you type python you get the python in that directory which is the Apple supplied one nut you have installed Django for the Macports one so python does not see it.
To fix you need to have /opt/local/bin earlier on the path than the /Library one. even better remove that /Library entry and use port select python ... to choose which python to run the Macports 2.7 or Apple's or others
As for the django-admin-2.7.py issue, Macports allows you to have several versions of python at once so code depending on eth version has the version add into the script names e.g. you could have a django-admin-2.6.py as well if you installed the py26-django package. This also applies to python itself however python also adds into the port select mechanism so you set a default version.

How to install/use django-inlinecss

I need to use this plugin plugin in my app, but i have no idea about how to install and use it. So far, I have found this fork of the mentioned plugin that adds a setup.py script. After issuing the commands python setup.py build and python setup.py install, I added 'django_inlinecss' to my INSTALLED_APPS setting, but still get the following error:
.
. (rest of the traceback)
.
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named django_inlinecss
How can I install this plugin and use it properly?
Sorry about the inconvenience - I didn't realize people had really started to use that library! (It's great to have people actually finding it useful by the way!)
Anyway, I've released it on Pypi, so you should now be able to just do a:
$ pip install django-inlinecss
If you have issues please open a ticket over at:
https://github.com/roverdotcom/django-inlinecss
I had the same problem, so I forked django-inlinecss original repostory and fixed the problem.
You can use
pip install git+https://github.com/fjsj/django-inlinecss.git#18f2f8e5b5453f067dff0d6c0c2ae3066e56d554
to install it successfully. It was missing a packages=find_packages(), line in stevejalim's setup.py.

Compiling node.js on Cygwin

I'm trying to build node.js on my Windows XP box (Yes, it IS painful, thanks.) using Cygwin following Ryans instructions here.
Sadly calling "./configure" from the node source directory barfs up this:
$ ./configure
/home/LWE/sources/node.js/wscript: error: Traceback (most recent call last):
File "/home/LWE/sources/node.js/tools/wafadmin/Utils.py", line 274, in load_module
exec(compile(code, file_path, 'exec'), module.__dict__)
File "/home/LWE/sources/node.js/wscript", line 12, in <module>
import js2c
File "/home/LWE/sources/node.js/tools/js2c.py", line 35, in <module>
import jsmin
File "/home/LWE/sources/node.js/tools/jsmin.py", line 1
../deps/v8/tools/jsmin.py
^
SyntaxError: invalid syntax
I'm absolutely not into Python so I'm having a hard time figuring this out. Am I missing some dependency or what?
I'd expect that there is some simple little configuration switch that I have to turn, to make this work. I just don't know where/what/why/...
I compiled node.js on my Mac before from the very same sources and that worked like a charm. And I also can't imagine that the build script from the node repository itself is broken.
PS: It's a totally fresh and up to date Cygwin installation with Python 2.6.5.
I also had a problem getting nodejs to compile using cygwin - also a Python issue. I eventually found a reference to having to rebase the cygwin DLL links to make everything work. Of course I couldn't find my original source for help. But I remembered enough to find similar help.
So from http://avalanche123.tumblr.com/post/855374337/nodejs-mongodb-tinyurl
I remembered that you can stop all cygwin processes, run ash (a minimal shell) that is typically found at C:\cygwin\bin\ash.exe and then, in this shell, run "/usr/bin/rebaseall"
Once I had run the rebaseall command I could, using the normal cygwin shell, successfully run the ./configure script for the nodejs source and proceed to "make" and "make install" nodejs.
This is old, but for anyone referencing this page: jsmin.py is a symbolic link. If you are using Git from msysGit in Cygwin, symbolic links will not be created properly. The Git client that comes with Cygwin deals with these pretty decently most of the time, however every now and then it barfs. If you bring up jsmin.py in an editor, you will see it actually contains the path to the file it is supposed to be linking to. To fix this and move on to compiling:
# from the node.js source directory, run:
% cd tools
% ln -fs `cat jsmin.py`
This will recreate the symlink pointing to the proper location. From here, re-run ./configure and you are all set.
A full set of build instructions is available at Github.
I had no problems using Ryan's current instructions -- until I tried install ing NPM as well, and then I got no output. If you are using cygwin and installing node.js, be sure to use the "works" tag when you git the file, instead of a specific version number. Otherwise, no output/non working npm.
Now to figure out getting mongo setup properly...