Python Sass unable to load DLL - django

On Windows, Python 3.4 64bit.
Installed libsass, but unable to run it.
Probably something to do with the 32bit vs 64bit.
pip install libsass
Requirement already satisfied (use --upgrade to upgrade): libsass in c:\python34\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): six in c:\python34\lib\site-packages (from libsass)
python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import sass
Traceback (most recent call last):
File "", line 1, in
File "C:\Python34\lib\site-packages\sass.py", line 24, in
from _sass import OUTPUT_STYLES, compile_filename, compile_string
ImportError: DLL load failed: %1 is not a valid Win32 application.
Help!

You should just install the appropriate wheel from: https://pypi.python.org/pypi/libsass (libsass-0.8.3-cp34-none-win_amd64.whl)

I just experienced a similar error:
File "K:\Python27\lib\site-packages\sass.py", line 26, in <module>
from _sass import OUTPUT_STYLES, compile_filename, compile_string
ImportError: DLL load failed: The specified module could not be found.
After a bunch of searching, it looked like on Windows I was missing the needed C++, and again, being Windows, the simplest way to fix this was to update VisualStudio with the C++ library.
Error is gone and libsass is working great after doing this.
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit(Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>> import sass
>>> print sass.compile(string='a { b{ color: blue; } }')
a b { color: blue; }
I know it doesn't directly answer the question, but thought I'd leave the solution I found here, for those who are in the process of losing a couple hours like I did.
I had Visual Studio 2013 - installed Visual Studio Community 2015 (making sure to select the C & C++ libraries)

The libsass DLL ("_sass.pyd" in the python world) probably misses some of its dependencies.
You can just install the small "Visual C++ Redistributable for Visual Studio 2015" to get that bunch of missing C++ components.

Related

Unable to import blpapi

I have almost spent many hours trying to make bloomberg API work with my Python 2.7 installation and still no luck. Bloomberg HelpDesk doesn't support it anymore so there is no help from them. Any help is much appreciated:
C:\Users\user>python
Python 2.7.16rc1 (v2.7.16rc1:baacaac06f, Feb 16 2019, 22:56:10) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import blpapi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\blpapi\__init__.py", line 11, in <module>
raise debug_load_error(error)
ImportError:
---------------------------- ENVIRONMENT -----------------------------
Platform: Windows-7-6.1.7601-SP1
Architecture: ('64bit', 'WindowsPE')
Python: 2.7.16rc1 (v2.7.16rc1:baacaac06f, Feb 16 2019, 22:56:10) [MSC v.1500 64 bit (AMD64)]
Python implementation: CPython
blpapi 64-bit will be loaded from: "C:\blp\blpapi_cpp_3.12.3.1\bin\blpapi3_64.dll"
blpapi 32-bit will be loaded from: "C:\blp\blpapi_cpp_3.12.3.1\bin\blpapi3_32.dll"
System PATH: (* marks locations where blpapi was found)
"C:\Program Files\Java\jdk-12.0.2\bin"
"C:\Python27\"
"C:\Python27\Scripts"
"C:\Windows\system32"
"C:\Windows"
"C:\Windows\System32\Wbem"
"C:\Windows\System32\WindowsPowerShell\v1.0\"
* "C:\blp\blpapi_cpp_3.12.3.1\bin"
blpapi package at: "C:\Python27\lib\site-packages"
Current directory: "C:\Users\user"
----------------------------------------------------------------------
No module named _versionhelper
Could not open the C++ SDK library.
Download and install the latest C++ SDK from:
http://www.bloomberg.com/professional/api-library
If the C++ SDK is already installed, please ensure that the path to the library
was added to PATH before entering the interpreter.
This issue is usually related to not being able to find shared libaries because of improperly set environment variables. I would take a look at installing this via Conda. Try
conda install -c conda-forge blpapi
Just make sure whatever distribution of python you are interested in is packaged on conda, as discussed here.
I did 2 things to solve an issue similar to that:
1- I installed Microsoft Visual Studio making sure I have the following components:
C++/CLI Support
VC++ 2015.3 v14.00 (v140) toolset for desktop
Visual C++ MFC for x86 and x64
Visual C++ ATL for x86 and x64
2- I manually copied the .dll files in C++API\lib (blpapi3_32.dll and blpapi3_64.dll in my case) into C:\windows\system32 where all the dll files that system uses.
Also, I copied the dll files in in C++API\lib into C:\blp\DAPI, replacing the new ones with the old ones.
Somehow, Path variable wasn't successful enough to find the dlls in the API folder.

Cannot run python 3.5 along with python 2.7.4 in Windows 10

I am trying to install Python 3.5.0 alongside with Python 2.7.4.
C:\Users\Animesh>python
Python 2.7.4 (default, Apr 6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
C:\Users\Animesh>py
Python 2.7.4 (default, Apr 6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
C:\Users\Animesh>py -2
Python 2.7.4 (default, Apr 6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
C:\Users\Animesh>py -3
Fatal Python error: Py_Initialize: unable to load the file system codec
File "E:\Python27\Lib\encodings\__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Current thread 0x00003514 (most recent call first):
I tried a bunch of commands as shown above but python 3.5 does not seem to work. I even tried creating a project on PyCharm using the Python 3.5 interpreter but it gives that same error.
How should I rectify this error?
The official installer for Python will install 3.5 in C:\Program Files\Python 3.5.
It will automatically add this path to your PATH variable (if you tell it). It seems like you did not enable this option.
In your PATH (not PYTHONPATH) setting.
You can get to this by going to the Settings application and searching for environment, then clicking on "Edit environment variables for your account" - this will open a properties window; click Environment Variables on the bottom to load the settings for your account.
You need to add the path manually to the PATH variable, and remove the E:\Python2.7 path.
Do this, then restart your command prompt and the default Python version will be 3.5.
For PyCharm, you can just add a new local interpreter in settings (CTRL+ALT+S) and point it directly to the location where you installed Python 3.5.
Since both interpreters are named python.exe, the first one found in your PATH will be executed. In practical terms this means, whatever is in your PATH is the default Python for your system. To execute the other version, you need to point to it explicitly.
If you have Python 2.7 in E:\Python2.7 and Python 3.5 in C:\Program Files\Python 3.5, pick the one you want to be the default and add the path to it in your PATH environment variable - you can always refer to the other installation by typing the full path to the python.exe file.
C:\>python.exe # this will launch whatever is found first in your `PATH`
C:\>E:\Python2.7\python.exe # explicitly launch the 2.7 version.
As far as PyCharm is concerned, it will read PATH and pick up the default interpreter, you can add the other one in your settings by browsing to its location.
Then, when creating a new project, you can pick which version you want to work with.

TensorFlow no attribute 'make_template'

I am trying to get familiar with tensorflow and NNs. I recently crashed into this problem when I tried to use tensorflow.make_template(). I first noticed that there were no auto-complete option in the IDE I use, and then I just tried to call the function from the python cmd:
$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.make_template()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'make_template'
>>>
I installed tensorflow from sources, and the protobuf version installed is:
$ git submodule status
55ad57a235c009d0414aed1781072adda0c89137 google/protobuf (v3.0.0-alpha-4-179-g55ad57a)
I haven't faced any similar behaviour with other tensorflow functions so far.
Any ideas about what's the issue causing this one?
As noted in the comments, this issue was due to a mismatch between the installed version of TensorFlow (0.5.0) and the downloaded source (0.6.0).
To upgrade to the latest development version of TensorFlow, follow the instructions to install from source, then build and install the PIP package based on that source.

Installing Pygame on 64-bit Windows 7 and 64-bit Python 2.7

The title says it all. I do see similar questions, someone suggested about http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame, but all the pygame downloadable files are in .whl format which I have no idea how to run on Windows 7. I tried "cd [directory] > pip install [filename]" without success.
This worked from me (Windows 7, python 2.7, 64 bit):
pip install C:/Users/ujjwal.karn/Downloads/pygame-1.9.2a0-cp27-none-win_amd64.whl
I downloaded the file pygame-1.9.2a0-cp27-none-win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame as well.
In general, whl files are installed with pip:
pip install whatever.whl
Open the .whl file through WinRar and just extract the contents(you will find 3 folders) into your Python folder.
For example : if you had installed python 2.7.3 in C:, then your directory to extract will be C:\Python27
You are doing right. Please just check python command it should display win64
C:>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
tel)] on win64 Type "help", "copyright", "credits" or "license" for more information.
if output is win32 install pygame‑1.9.2a0‑cp34‑none‑win32.whl

Pygame works in IDLE, but not in CMD\PowerShell [2.7.3][Win7] [duplicate]

The title says it all. I do see similar questions, someone suggested about http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame, but all the pygame downloadable files are in .whl format which I have no idea how to run on Windows 7. I tried "cd [directory] > pip install [filename]" without success.
This worked from me (Windows 7, python 2.7, 64 bit):
pip install C:/Users/ujjwal.karn/Downloads/pygame-1.9.2a0-cp27-none-win_amd64.whl
I downloaded the file pygame-1.9.2a0-cp27-none-win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame as well.
In general, whl files are installed with pip:
pip install whatever.whl
Open the .whl file through WinRar and just extract the contents(you will find 3 folders) into your Python folder.
For example : if you had installed python 2.7.3 in C:, then your directory to extract will be C:\Python27
You are doing right. Please just check python command it should display win64
C:>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (In
tel)] on win64 Type "help", "copyright", "credits" or "license" for more information.
if output is win32 install pygame‑1.9.2a0‑cp34‑none‑win32.whl