How to install SciPy on an Azure C# webapp? - python

I have a website built with .Net Core 1.0 (C#) and deployed it to Azure WebApp (32 bit mode).
The app uses some python scripts and I was able to create a virtual env (3.4.1) and successfully installed numpy (1.11.0) with pip install numpy.
The problem I'm facing is that I can not install SciPy. Trying pip install scipy fails because of compiler issues which I understand.
Next try was to download Christoph Gohlke's Python Extension Packages for Windows (from here), copied it to my web app and tried to run 'pip install scipy-0.18.0-cp34-cp34m-win32.whl' without success. The error I get is:
scipy-0.18.0-cp34-cp34m-win32.whl is not a supported wheel on this platform.
Storing debug log for failure in D:\home\pip\pip.log
pip.log contains the following:
scipy-0.18.0-cp34-cp34m-win32.whl is not a supported wheel on this platform.
Exception information:
Traceback (most recent call last):
File "D:\home\site\wwwroot\env\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "D:\home\site\wwwroot\env\lib\site-packages\pip\commands\install.py", line 257, in run
InstallRequirement.from_line(name, None))
File "D:\home\site\wwwroot\env\lib\site-packages\pip\req.py", line 167, in from_line
raise UnsupportedWheel("%s is not a supported wheel on this platform." % wheel.filename)
pip.exceptions.UnsupportedWheel: scipy-0.18.0-cp34-cp34m-win32.whl is not a supported wheel on this platform.
I have tried to create a requirement.txt file as stated in Troubleshooting - Package Installation. However since it's not a python app, but instead a dotNet Core C#, it doesn't seem to care about the requirement.txt file and don't see anything about it in the deploy.cmd file.

#mdeblois, your understanding is correct, please see the offical explaination below.
Some packages may not install using pip when run on Azure. It may simply be that the package is not available on the Python Package Index. It could be that a compiler is required (a compiler is not available on the machine running the web app in Azure App Service).
For this case, the solution is that you can refer to the section Troubleshooting - Package Installation of the offical tutorial to know how to deal with.

Related

AWS Lambda and X-Ray: (Python) How To Install

TL;DR How do I install AWS X-Ray sdk, because the pip install doesn't seem to get the full package
Hello Folks,
I'm working on trying out AWS X-Ray for my Python lambda. I know the library is large, but I wanted to get a POC before putting it into a layer. The issue is that when I install it, it doesn't seem to get installed.
When I run pip install -r requirements.txt I see that it installs two packages, aws_xray_sdk and aws_xray_sdk-2.9.0.dist-info. When I look into these packages I see that they are 740 kilobytes altogether (makes me think this is a stub of some sort)
When I upload my lambda and test it, I get the following error even though the directories are in my venv:
[ERROR] Runtime.ImportModuleError: Unable to import module 'users/main': No module named 'aws_xray_sdk' Traceback (most recent call last):
Any help is greatly appreciated.
To install the X-Ray SDK for Python, you simply do pip install aws-xray-sdk and that should work. This is explained in the documentation.
If this is not working, there is something else that's wrong with your setup.
The issue was that I was not putting my dependencies in the root of my .zip file as the docs clearly show ='(
4. Create a deployment package with the installed libraries at the root.

Import ldap in python gives gives "DLL load failed" error

I'm using the "import ldap" in a python code. This is on a windows 10 machine.
I installed the python-ldap module
pip3 install python-ldap
Installed the dependencies based on the instructions at Python Can't install packages
Also resolved all the pip deployment issues based on Installing python-ldap in a virtualenv on Windows
I'm now getting the following error when executing the import ldap statement. am I missing something here? Any ideas to resolve it?
thon39\site-packages\ldap\__init__.py", line 34, in <module>
import _ldap
ImportError: DLL load failed while importing _ldap: The specified module could not be found.
Visit the unofficial Python binaries page:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
Download the appropriate WHL package for your system.
For example, if you're using Python 3.8 on an x64 system, download python_ldap‑3.3.1‑cp38‑cp38‑win_amd64.whl
(hint: do NOT download the +sasl version unless you have the Cyrus SASL code running on your system...)
Start the VirtualEnv for your project, if you're using one (C:\Users\youruser\.virtualenv\YourVirtualEnv\Scripts\activate.bat) -- if you're not, skip this step.
Then run pip3 install C:\Path\To\python_ldap_x.x.x-cpXX-cpXX-winXX.whl and this should install the Python DLL (pyd) file for you.

django Failed to build mysqlclient [duplicate]

I want to install MySqlclient on my windows system. I am Currently using Python 3.6. After going through the various post over Stackoverflow, I could Not find the correct way.
This is what I have done so far:
1) Installation by using pip pip install mysqlclient. Error:
Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools" http://landinghub.visualstudio.com/visual-cpp-build-tools
I already have Microsoft Visual C++ installed on my laptop. Some are saying you need 2015 edition.
2) Installation by using wheel file pip install mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl. Error:
Requirement mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl looks like a filename, but the file does not exist.
mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
2.1) Changing the whl file to different version pip install mysqlclient-1.3.13-cp36-cp36m-win32.whl. Error:
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\Foxtrot\\Desktop\\finaltest\\mysqlclient-1.3.13-cp36-cp36m-win32.whl'
Other things that are done: updated setuptools, updated wheel.
Had the same problem, searched the web etc. Here this answer:
mysql-python install error: Cannot open include file 'config-win.h'
It has all the instructions. In short go to this site: https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient:
At that website you will find
mysqlclient‑1.3.13‑cp36‑cp36m‑win32.whl
mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl
Download the correct file for your platform.
Then use your downloaded wheels file with pip and you're done:
pip install c:\mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl
The https://www.lfd.uci.edu/~gohlke/pythonlibs has lots of lots of compiled libraries to solve the problem of building them from source yourself. They even compile them for python 3.7 :)
Alternative Solution
You can also download Visual C++ Build Tools and then you should be able to install every (at least to my knowledge) version of mysqlclient with pip.
To do this go to this site: https://www.scivision.co/python-windows-visual-c++-14-required/ there you can find out which version of Build Tools you need and you can also find a link to download the installer. Be aware though Build Tools require more than 4GB of free disk space.
Tell pip not to use sources and use binary packages instead:
pip install --only-binary :all: mysqlclient
https://pip.pypa.io/en/stable/reference/pip_install/#install-only-binary
I can't find mysqlclient-1.3.13's whl file on PyPi. So you need to compile it from source. Unfortunately it's not easy. I'm not Windows guy, so I only can recommend guide like this
I am using python3.7 on Windows 10 operating system.
I had same issue and after a long research I had installed it successfully.
Install "Microsoft Visual C++ Build Tools"
AND
My OS is having 64 bit operating system but still then it need to install 32 bit version
"mysqlclient‑1.4.2‑cp37‑cp37m‑win32.whl"
Download binary wheels from "https://www.lfd.uci.edu/~gohlke/pythonlibs/" and run command
pip install [path_to_downloaded_file] eg: C:\Users\Ds\mysqlclient-1.4.2-cp37-cp37m-win32.whl
use pipenv instead of pip if you are using virtual environment.
The error means that the package has not yet been compiled for your versions of OS and Python. So pip tries to build it from the source for you.
There are two possible solutions.
The first option is to install the most recent version of Microsoft Visual C++ Build Tools. Just go ahead and download it from the Microsoft website. Then pip should be able to compile the package.
Another option is using an unofficial binary. As mentioned here, a resource proved to be useful is https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python . Just download the pre-compiled package and install it using
pip install c:\path-to-a-pre-compiled-package
Had the same problem just day.
Tried to install mysqlclient on a Windows Server R2.
[...]
Tl;dr
"MySQL Connector C 6.1" was installed in the wrong directory: "C:\Program Files\MySQL" instead of "C:\Program Files (x86)\MySQL" where it should be for me.
--> Copied "MySQL Connector C 6.1" to "C:\Program Files (x86)\MySQL" Directory.
"C:\Users\MoBoo\AppData\Local\Temp" was Read-Only: Therefore pip couldn't compile files into Temp dir.
--> Allow Write access to "C:\Users\MoBoo\AppData\Local\Temp" Directory.
Here is what worked for me. I uninstalled mysql and re-installed it.
pip uninstall mysqlclient
Then simply re-install, so it picked the current version "1.4.2.post1"
pip install mysqlclient
Which interestingly, works straightaway.
for this error, most of user's suggest to install vs build but there is an alternative which works perfectly in my case and is sure for you too.
Download latest MySQL client from here
mysqlclients
Here you can see many version but prefer to download the latest one which has 32 bit and 64-bit files.
download theme and past the file on your projects root folder then run the same command but with the full file name of downloaded mysqlclient.
like: pip install mysqlclient‑1.4.6‑cp38‑cp38‑win32.whl
in my case, the file is this
also if have already the XAMPP server then you can use its PHPMyAdmin with python.
You just need to change on your roots setting.py file for this.
Something like this
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydjango',
'USER': 'root',
'PASSWORD':'',
'HOST':'localhost',
'PORT':'3306',
}
}
The port is the same which you see on xampp panel just before the start button of MySQL.
After changing this you just again start your server by hitting this command
python manage.py runserver
If you didn't see any error then congratulations you successfully connected with MySQL database.
Enjoy...
The easiest way to solve this problem is to download the correct version of MySQL client that supports the python version installed on your system.
MYSQLclient download link: https://pypi.org/project/mysqlclient/#files
Check the python version installed in your PC:
I was using Python version 3.7 and the same error was happening.
After trying all the possibilities, simply reinstalling the newest Python version (3.10.7 in my case) solved the issue.

PyCluster unable to install package

This is the error I am getting when trying to install PyCluster. I am using python 2.7 with anaconda in spyder IDE and on windows.
Downloading/unpacking PyCluster
Getting page http://pypi.python.org/simple/PyCluster
URLs to search for versions for PyCluster:
* httpss://pypi.python.org/simple/PyCluster/
Getting page httpss://pypi.python.org/simple/PyCluster/
Analyzing links from page httpss://pypi.python.org/simple/pycluster/
Could not find any downloads that satisfy the requirement PyCluster
No distributions at all found for PyCluster
Exception information:
Traceback (most recent call last):
File "C:\Users\anankuma\AppData\Local\Continuum\Anaconda\lib\site-packages\pip-1.2.1-py2.7.egg\pip\basecommand.py", line 107, in main
status = self.run(options, args)
File "C:\Users\anankuma\AppData\Local\Continuum\Anaconda\lib\site-packages\pip-1.2.1-py2.7.egg\pip\commands\install.py", line 256, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Users\anankuma\AppData\Local\Continuum\Anaconda\lib\site-packages\pip-1.2.1-py2.7.egg\pip\req.py", line 1011, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "C:\Users\anankuma\AppData\Local\Continuum\Anaconda\lib\site-packages\pip-1.2.1-py2.7.egg\pip\index.py", line 157, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for PyCluster
Please suggest a workaround. Thanks
here is the package there is no source or binary available to download.
a module (pyclustering) with similar name.
The Python Package Index (PYPI) is a repository of software for the Python programming language.
One can download packages manually or using pip install
One can upload binary and source packages as well.
For example this package has a source and some binaries as well
Python Wheels and Python Eggs are ease to install, mostly used on windows.
However manual install can be done using MS Windows installer files downloaded directly form PYPI
Had a similar situation installing this Pycluster package
pip was trying to build the package because there were no official wheels
for Python 3.5 & windows.
Solved it by downloading an unofficial wheel from here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycluster
There are many wheel files on this website.
Try different versions to see whichever works the best for you.
You can install the .whl file this way using Anaconda Prompt with the following code
pip install Pycluster-1.56-cp36-cp36m-win_amd64.whl
install with pip:
pip3 install pyclustering
it even works with Anaconda prompt

Installing scikit-learn and scipy on elastic beanstalk with pip and requirements.txt

When deploying to elastic beanstalk I keep getting the error:
Partial import of sklearn during the build process.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-Le610u/scikit-learn/setup.py", line 247, in <module>
setup_package()
File "/tmp/pip-build-Le610u/scikit-learn/setup.py", line 237, in setup_package
.format(scipy_req_str, instructions))
ImportError: Scientific Python (SciPy) is not installed.
scikit-learn requires SciPy >= 0.9.
Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html
My requirements.txt has both scikit-learn and scipy in it.
Why is this occurring? I don't want to be installing packages manually, and was under the impression pip would sort out the installation order for me (it's currently trying to install scikit-learn before scipy). It might be worth noting the same requirements.txt works perfectly fine on my local computer.
What can I do to fix this?
Edit: If I change the order of the entries in requirements.txt so scipy is above scikit-learn, it works just fine. I'd still like to know why this fails the other way around though, since pip freeze > requirements.txt will override it with alphabetical ordering.
Requirements files are files containing a list of items to be installed using pip:
Logically, a Requirements file is just a list of pip install arguments placed in a file.
Therefore, the entries in your requirements.txt will be processed sequentially by pip. As it is now, pip doesn't have true dependency resolution and scipy lacks proper install_requires in its setup.py, you have to tell pip install scipy first. (see "setup.py vs requirements.txt" by Donald Stufft if you are interested)
The reason why the same requirements.txt works on your local computer might be you have an installed scipy before running the script. You can verify this by creating a clean python enviroment by virtualenv on your computer and run the script again.

Categories