Error when installing pycrypto - python

I'm trying to install Fabric on my PC (with Windows + setuptools). It was giving me an error, since I have older version of pycrypto.
When I was trying to install latest version I stumble upon "Unable to find vcvarsall.bat" error. I googled something about MinGW, so I installed that too. I've added it to my Windows PATH, but now i'm getting another error, which looks like this: "command 'gcc' failed: no such file or directory." What do i do now? Found something about gcc-mingw, which is some version of MinGW that could help?
Why is has to be so damn complicated :D.
New development. Managed to install pycrytpo and fabric, but still can't run anything in the latter. New error says: "ImportError: no module named win32api". Quick google search says something about PyWin, but easy_install can't find it and it looks like it's abandoned. Any ideas?

Well, it's so complicated because C (C++? Can't remember what they used at the moment, but I am pretty sure they used C) is much, much better at math than Python, so the math pieces of PyCrypto are all written in C. It does have a _slowmath module if the compiled versions aren't available, but it's name is telling... it is much slower.
gcc is the GNU Compiler Collection (<!-- an edit, I had thought it stood for GNU C Compiler, but apparently my knowledge was dated). It is a bit legendary, but apparently your version of Windows has not heard of it. First question though, have you closed the "DOS prompt" and restart it? (it's in quotes because the people at superuser once yelled at me because I did not sufficiently acknowledge its inferiority) Environment Variables in Windows do not update during a "DOS session" (or whatever it is supposed to be called).
If you have, chances are that it can be found inside of the MingW install director -- if there is a bin folder I'd check there first. If not, I would search for gcc.exe and make sure that it's path is part of PATH. Then,
If all else fails, you might be able to get more info on MingW here.

Related

GeoDjango - FileNotFoundError: Could not find module 'C:\OSGeo4W\bin\gdal304.dll' (or one of its dependencies)

I am trying to install GeoDjango what turns out to be much harder than I thought. After I installed the OSGeo4W on my 64 Bit Windows 10 system I set everything up in the settings.py file but now I get this error:
FileNotFoundError: Could not find module 'C:\OSGeo4W\bin\gdal304.dll' (or one of its dependencies). Try using the full path with constructor syntax.
I also set the GDAL_LIBRARY_PATH but it just won't work.
GDAL_LIBRARY_PATH = "C:\\OSGeo4W\\bin\\gdal304.dll"
This is my C:\OSGeo4W\bin path and as you can see the gdal304.dll file is there
My Python is on version 3.10.6
Django is on version 4.1
I already tried to solve it by myself for a week but slowly I have no idea left on what to do
I ran into this problem too, since I updated my old GEO Django Setup today.
You may use a Docker Image as suggested by the others, but I prefere a native solution, since I don't want to spin up Docker every time I start coding.
Your solution is in the brackets: (or one of its dependencies)
You may look up the transitive dependendencies from gdal304.dll. There are several tools for this (see here). I'm using here now the Git integrated MinGW - Shell that has ldd installed. This should be the case for any (newer) Git installation on Windows.
As you can see, some dependencies are already fullfilled from your operating system. Others that are missing, have to be fullfilled from OSGeo4W. If you compare this with your bin directory from OSGeo4W you will see the Problem:
Sadly a simple "renaming" does not the trick. I was lucky and had not yet deleted my old OSGeo4W version. In the old files I then found the necessary DLL.
So, long story short: You need the jpeg.dll file.
There are sites like "windll.com" or "dll-files.com", but I would not recommend using them. I don't trust these sites. You may install something like "MSYS2", "Cygwin" or even "MVSC", install the "libjpeg-turbo" library and then finally copy & paste the necessary DLL file.
This is also suggested on the official Site for libjpeg-turbo: https://libjpeg-turbo.org/Documentation/OfficialBinaries
But this seems like a lot of work for someone who just want to have the DLL file, but then again: Never download a library blindly from the Internet and load it into your application. These libraries could do anthing!

How to install python developer package on Windows?

I ran into the same problem as here. So I tried to install python developer package but I didn't find the way to do this.
Cython's helloworld instruction doesn't contain any info about it, which seems strange and stupid to me to not include basic requirements into instruction, named "Basic Tutorial" (Sorry if I don't get something about it.)
Anyway... I'm using Windows 10, PyCharm, virtual environment with python 3. When I went to package install window, search result contained 5 packages:
So, which one?
I tried to install one, but it gives me an error:
I met this error in the past with some other package already. PyCharm's suggestion is to run that command from terminal. But from my experience that never helped. Usually solution was either to change name (because some names are right for Python 2.x, other for Python 3.x), or to download the package (egg/wheel) manually and install it offline.
This question was asked before already, but that one is for linux, which is not the case for me.
Can someone save some time for me and future generations, please? ;)
How do I install it and make Cython's helloworld example work?

I/O Error: Bad File Descriptor, can not save python file

I recently uninstalled and reinstalled python, and i have not been able to save one of my programs since.
When i hit ctrl+S, IDLE throws me a window saying I/O Error: Bad file descriptor. I can not even save my file!
As it turns out i don't think it has anything to do with the actual code. No matter what is in the program, it still throws this error when i try to save, unless there is no code whatsoever!
IF anyone knows why this error is occurring, please tell me or post an updated version of the code, any help is appreciated
I am using Windows 10, Python 3.7.3 64-bit [a couple days ago i uninstalled (just through windows settings) 32-bit and installed 64 from the python website]
I have experienced the same issue.
In my case the Windows 10 Defender was the root cause.
I added in Windows Defender Ransomware Protection the python.exe of my used IDE and the issue disappears.
In Windows, it is theorically possible to install 32 bits and 64 bits versions of Python side by side, and it should work with a genuine installation. But dragons are waiting around:
it is possible to have shortcuts pointing to a wrong location.
if the PATH has been changed to allow direct usage of the python, or pip command from the command line, risk is that you use the wrong tool
if any Python environment variable has been set, problems are almost guaranteed
Furthermore, Python can be installed either for the current user or for all users, which adds more possibilities for inconsistancies.
Once an installation is deemed broken, uninstalling one of the versions is generally useless on can even cause more problems. Long story short, if you have entered the world of inconsistancy, you must clean up everything.
My advice here is:
find where the Python versions were installed and note it
find if additional tools (py) have been installed and try to find which ones
uninstall every Python version
control that the installation paths are empty
search the environment and PATH for any Python related information and remove them
When everything looks good, reinstall from the installation wizard.
Hopefully it should work. If it does not I cannot help: despite being presented as an end user friendly system, Windows is a very feature rich and complex OS and trying to fully analyze a Windows system is beyond the capacity of most users, including most power users and sysadmins. At a point, the only possibility left is to reinstall the full OS and then cleanly install everything back... when it is possible...

Python - C Compile errors - gcc failed

Oftentimes when I try to install a Python package, installation will fail with following error: "error: command 'gcc' failed with exit status 1".
I am at loss. Most things I try to instal fail. I am losing my mind on this. Really like the language, but this is driving me crazy. Spent countless hours looking for solutions, to no avail.
Probably the problem comes from my environment. Here's how I am (insanely?) trying to run things:
Windows 7 machine
MS Visual C++ 14 redist freshly installed
Python 2.7.15 through Jupyter/SageMath 8.3 (can't execute Python through Console because throws 16bit error)
P.s.: I'm an ignorant, but I know it, so don't bother. Any help appreciated.
Ok, I found a workaround/solution.
I am suspecting that the Python kernel provided with SageMath is not a 100% complete/functional Python kernel/core. I reluctantly conceded to install a standalone Python "kernel" (not certain the term is technically correct) from Python.org, v. 2.7.15, using the standard prebuilt binaries for x64 Windows systems. Installed it in a different folder than Sage of course, added it to the system Path variable, and guess what? Yeah, issues resolved. Everything now installs flawlessly - well, mostly, but at least now it's down to an acceptable level of failure. So I installed Jupyter on this kernel and I can now continue my development the way I like it.
I mean, I would if a few hundred lines of code weren't too many for the computer on which I am working... Since it's lagging a bit, I will need to resort to other 'IDE' solutions. But that's another story altogether...
Thanks much nonetheless to everybody who bothered dropping a line by. Especially #Red Cricket, who helped me reconsider my reluctancy to install another Python kernel alongside SageMath's. Not a big fan of duplication, but hey, enough time lost there.

How do I use script provided by Anaconda without using the given python?

It seems that when I install Anaconda, I can't neither normal python or the python provided with Anaconda, even though Anaconda already in path.
I do realize that Anaconda also come with a python, but it come both with 2.7 and 3.2, but it's kinda scary due to the path conflict that I had earlier. It may ended like this, fortunately it goes normal when I uninstalled it
After uninstalling, my plan is to only take the installed library then uninstall Anaconda:
Reinstall Anaconda
Copy the library (scipy,numpy,etc)
Paste it to normal Python2
Uninstall Anaconda and its family
Hapilly ever after
But this seems not foolproof, is there any better way?
Note: As I mentioned, I know Anaconda have python avaliable too, so my other alternative is to uninstall normal python and just use Anaconda. But again, when I saw they provided two version, I decided to take the way mentioned above.
Python is getting more complex and installing libraries in a way that they work is becoming more brittle. You can install pip which will try to download the source code for libraries and compile them for your OS (which might or might not need a C compiler locally installed and working).
Anaconda tries to solve this hazzle by providing a set of working, well maintained libraries which you can install easily using the conda tool. When I installed the product last time, it didn't try to install both Python 2 and 3 - you have to select either. It also asks whether it should add itself to your path; you can say "no".
But you have to chose between: "I know exactly what I'm doing" - then you're on your own. Or you can say "I don't know enough" and trust some unknown expert to get it right most of the time.
You copy&paste approach might work since I haven't seen a Python library where absolute paths were compiled in. On the other hand, some of those libraries have hundreds of thousands of lines of code. It's hard to say which one of them will break when you start moving things around.

Categories

Resources