When the command is executed python manage.py runserver - django

When the command is executed :
python manage.py runserver
error :
C:\Users\Mr-py-dj\Desktop\sageteam-project\venv\lib\site-packages\khayyam\algorithms.py:19: UserWarning: The C extension is not available. Switching to fallback python pure algorithms,so it's about 1000X slower than C implementation of the algorithms.
"The C extension is not available. Switching to fallback python pure algorithms,"
why???

Install build-essential and python2-dev or python3-dev
Download the latest release and extract. then
python setup.py build_ext --inplace
pip install -e .

Related

python - pip installs but cannot import

I've read a lot of posts about this but none of the solutions have worked for me. I'm trying to get a module called nsxramlclient installed, shows successful installation with pip but cannot import from any location outside of the /Users/Nathan/Library/Python/2.7/lib/python/site-packages.
Uninstall does work after some fidgeting with brew using the recommendations found with brew doctor. Here are some vitals:
Running OSX python 2.7.10
PIP 18.1
which -a pip = /usr/local/bin/pip
which -a python = shows 2 directories:
/usr/local/bin/python
/usr/bin/python
python -c 'import sys; print(sys.path)'
['', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload']
pip list | grep nsxramlclient
nsxramlclient 2.0.7
It has to be a path issue since I'm able to import it from the directory that the module is located. I just don't know the proper method to repair this since I'm fairly new to Python and I don't want to mess it up worse that it is already.
Looks like I did end up getting it to work finally. What I had to do was to re-install python with brew:
brew re-install python#2
then I needed to re-install the modules I needed with pip. Having OTHER issues now but at least this one is fixed.

temporary use of release candidate python version in tox

I am using tox to test my python packages. Now that python 2.7.13 has a release candidate, how do I test against this version using tox without immediately replacing my current python 2.7 version for normal use?
I know how to specify a path for python when creating a virtualenv and then I can install and run py.test. Tox builds its own virtualenv and I don't know how to influence the python version installed beyond selecting py27, py26, py35.
How can I solve this?
You can influence this using the PATH, by extending your PATH before calling tox (at least on Linux, probably not on Windows).
To get some more fine grained control and to get that to work on Windows (where AFAIK you cannot set an environment variable for a single command usage like on Unix/Linux), you can use the tox extension package tox-globinterpreter (disclaimer I am the author of that package) which you can install with pip.
The package adds a --scan option to tox which writes out an explicit mapping from py27, py36, etc to a python executable.
E.g. I do:
tox --scan /opt/python/{2,3}.?/bin/python /opt/python/pypy2/bin/pypy
on my Linux based system, where /opt/python/X.Y is a link to the latest released Python version as installed in /opt/python/X.Y.Z (or the latest version in case of development version like 3.6), this gives as output:
interpreters:
python2.6 /opt/python/2.6/bin/python
python2.7 /opt/python/2.7/bin/python
python3.2 /opt/python/3.2/bin/python
python3.3 /opt/python/3.3/bin/python
python3.4 /opt/python/3.4/bin/python
python3.5 /opt/python/3.5/bin/python
python3.6 /opt/python/3.6/bin/python
pypy /opt/python/pypy2/bin/pypy
When I change the scan to:
tox --scan /opt/python/2.6/bin/python /opt/python/2.7.13*/bin/python \
/opt/python/3.?/bin/python /opt/python/pypy2/bin/pypy
I get:
interpreters:
python2.6 /opt/python/2.6/bin/python
python2.7 /opt/python/2.7.13rc1/bin/python
python3.2 /opt/python/3.2/bin/python
python3.3 /opt/python/3.3/bin/python
python3.4 /opt/python/3.4/bin/python
python3.5 /opt/python/3.5/bin/python
python3.6 /opt/python/3.6/bin/python
pypy /opt/python/pypy2/bin/pypy
And tox -e py27 will be using the 2.7.13 release candidate. You can save the configuration file (in ~/.config/tox or %APPDATA%\tox) if switching back and forth, but rerunning the scan is pretty fast, so I would make a shell script/alias/batch file for that.

Import Error with certain modules in pyoptsparse

Hello everyone,
I have installed Openmdao, pyOpt and pyoptsparse on my computer. As my program works with the Scipy optimizer, I tried it with a random optimizer of pyoptsparse (that was 'ALPSO'). It worked and I was happy. But it turns out it seems to be the only one working.
Every time I try to use another one (like 'SLSQP', which is the default optimizer !), i get this message "pyOptSparse Error : There was an error importing the compiled SLSQP module", inside a frame made of '-' and '+'.
Does anybody know what to do ? I am using Ubuntu if it changes something.
Thanks to swryan for the link, i found the answer.
One of the possible answer was to put libgfortran.so.3 in anaconda2/lib, but i already had it.
They were also saying the problem was solved when installing anaconda 4.0+ but i also had the latest version.
What worked for me was to run : conda update libgfortran --force
Doing it without the --force retrogrades the scipy, which seems to disable scipy.optimize.least_squares. If you did that, you can then run conda update scipy --force
Did you get any errors when you ran 'python setup.py install' for pyoptsparse? I looked at the setup.py file for pyoptsparse and there are some instructions in there that you could try:
print("\nTo install, run: python setup.py install --user\n\n"
"To build, run: python setup.py build_ext --inplace\n\n"
"For help on C-compiler options run: python setup.py build --help-compiler\n\n"
"For help on Fortran-compiler options run: python setup.py build --help-fcompiler\n\n"
"To specify a Fortran compiler to use run: python setup.py install --user --fcompiler=<fcompiler name>\n\n"
"For further help run: python setup.py build --help"
)

Pyinstaller freezes an invalid binary when includes ZMQ

I'm trying to freeze a binary with PyInstaller that includes ZMQ code. When testing the application everything works fine with Python interpreter, but final binary does not work at all.
Note: A different code is used here to illustrate and simplify the error:
try:
import zmq
zmq.Context()
except Exception, e:
print str(e)
print 'end'
Python version is 2.7.6, Operating System is CentOS 6.7 and I'm working with a virtual environment which includes the following packages:
(Compiler)[user#machine test]$ pip list
backports.ssl-match-hostname (3.4.0.2)
certifi (2015.9.6.2)
cffi (1.2.1)
cryptography (1.0.1)
Cython (0.23.1)
distribute (0.7.3)
enum34 (1.0.4)
futures (3.0.3)
idna (2.0)
ipaddress (1.0.14)
Jinja2 (2.8)
M2Crypto (0.22.3)
MarkupSafe (0.23)
msgpack-python (0.4.6)
npyscreen (4.10.0)
pip (7.1.2)
psutil (3.2.1)
pyasn1 (0.1.8)
pycparser (2.14)
pycrypto (2.6.1)
PyInstaller (2.1)
pyroute2 (0.3.14)
python-iptables (0.9.0)
pytz (2015.4)
PyYAML (3.11)
pyzmq (14.7.0)
requests (2.7.0)
salt (2015.5.5)
setuptools (18.0.1)
six (1.9.0)
tornado (4.2.1)
tzlocal (1.2)
wheel (0.24.0)
And this other rpm package has been installed through YUM tool:
[root#machine test]# rpm -qa | grep -i zmq
python-zmq-14.3.1-1.el6.x86_64
Case ONE: Works with Python Interpreter.
(Compiler)[user#machine test]$ python test.py
end
Case TWO: Does NOT work after PyInstaller.
(Compiler)[user#machine test]$ pyinstaller --onefile test.py
...
12135 INFO: building EXE from out00-EXE.toc
12136 INFO: Appending archive to EXE /test/dist/tes
(Compiler)[user#machine test]$ /test/dist/test
/tmp/_MEIl3jKVa/zmq/libzmq.so: undefined symbol: crypto_secretbox_open
end
What I'm missing? Thanks in advance!
Problem seems to be fixed by downgrading pyzmq version from 14.X to 13.X (eg: 13.1.0 has been tested successfully).
I think pyzmq includes pyNacl (libsodium) libraries on 14.X and onwards. However, I have also tried to freeze with Pyinstaller after installing pyNacl (0.3.0) in my virtual environment and I got the same error.
Does anyone knows how to do this with latest version of pyzmq?

Is there a %config(noreplace) option for setup.py's bdist_rpm?

I am building a python package, and I want to distribute it via rpm using python setup.py bdist_rpm. However, I am including a configuration file, and I want any changes in there to remain if I ever upgrade the RPM on the machine it's installed on. Is there anyway to set a flag in the setup.py script or command that I don't want the RPM to replace the configuration file in case of upgrades? I'm on Python 2.7. Thanks!
python setup.py bdist_rpm --spec-only
This will create dist/*.spec, manually edit it. Especially change:
%install
python setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
%files -f INSTALLED_FILES
to:
%install
python setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT
%files
%{python_sitelib}/*
%config(noreplace) %{_sysconfdir}/yourconfig.conf
Note: you may add more lines to %files section, it depends what you put in buildroot. If you miss something rpmbuild from next step will report it as error.
Then you can build the SRPM using
rpmbuild -bs dist/*.spec
More resources can be found here:
https://fedoraproject.org/wiki/Packaging:Python
https://fedoraproject.org/wiki/How_to_create_an_RPM_package