5

I'm trying to install uwsgi for a django project inside a virtual environment; I'm using windows 10.

I did pip install uwsgi & I gotCommand "python setup.py egg_info".

So to resolve the error I followed this SO answer

As per the answer I installed cygwin and gcc compiler for windows following this.

Also changed the os.uname() to platform.uname()

And now when I run `python setup.py install``. I get this error

C:\Users\Suhail\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\_distutils\dist.py:275: UserWarning: Unknown distribution option: 'descriptions'
  warnings.warn(msg)
running install
C:\Users\Suhail\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
using profile: buildconf/default.ini
detected include path: ['/usr/include', '/usr/local/include']
Patching "bin_name" to properly install_scripts dir
detected CPU cores: 4
configured CFLAGS: -O2 -I. -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_IPCSEM_ATEXIT -DUWSGI_EVENT_TIMER_USE_NONE -DUWSGI_EVENT_FILEMONITOR_USE_NONE -DUWSGI_VERSION="\"2.0.19.1\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="19" -DUWSGI_VERSION_REVISION="1" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"
*** uWSGI compiling server core ***
[thread 1][gcc] core/utils.o
[thread 2][gcc] core/protocol.o
[thread 3][gcc] core/socket.o
[thread 0][gcc] core/logging.o
In file included from In file included from core/logging.c:2core/socket.c:1                      :
:
                                  ./uwsgi.h:172:10::
                                fatal error:  sys/socket.h: No such file or directory
 #include sys/socket.h: No such file or directory
 #include                            <sys/socket.h>sys/socket.h: No such file or directory
 #include

                        ^~~~~~~~~~~~~~^~~~~~~~~~~~~~


cc^~~~~~~~~~~~~~o mm
ppiillaattiioonn  cttoeemrrpmmiiilnnaaatttieeoddn..

In file included from t rcore/utils.c:1mi:
n
 uwsgi-2.0.19.1> t./uwsgi.h:172:10:ed .
fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
          ^~~~~~~~~~~~~~
compilation terminated.
Suhail Ahmed
  • 303
  • 2
  • 3
  • 15

1 Answers1

4

Step 1: Download this stable release of uWSGI

Step 2: Extract the tar file inside the site-packages folder of the virtual environment.

For example the extracted path to uwsgi should be:

\my_env\lib\site-packages\uwsgi-2.0.19.1

Step 3: Open uwsgi-2.0.19.1\uwsgiconfig.py And do the following edits:

import platform
...

Then wherever you encounter

...
os.uname()[x-index]
...

modify it with

...
platform.uname()[x-index]
...

Step 4: Finally, Open powershell and cd into \my_env\lib\site-packages\uwsgi-2.0.19.1 and run:

python setup.py install

Got an error? Check out this

Step 5: Run pip install uwsgi you'll get Requirement already satisfied:. Try pip freeze you'll see uwsgi is listed. Which means you have now successfully installed uwsgi. Congrats!


Reference

Suhail Ahmed
  • 303
  • 2
  • 3
  • 15
  • Not work, please help @Suhail Ahmed – trungducng Aug 11 '22 at 14:24
  • What's the error? And have you gone through https://www.journaldev.com/25757/c-compiler-windows-gcc – Suhail Ahmed Aug 12 '22 at 04:50
  • yes, Tried many time (the whole night) but got the same error as you mention in this question. If you have some time, Can you connect with me to help resolve this issue? – trungducng Aug 12 '22 at 06:07
  • 1
    tried with both uwsgi-2.0.19.1 and uwsgi-2.0.18 but both of them do not work. Besides, the command `python setup.py` is not correct, we have to use: `python setup.py install` – trungducng Aug 12 '22 at 06:24
  • Okay, I'm gonna delete and reinstall the uwsgi and lets see if some error pops in :) – Suhail Ahmed Aug 12 '22 at 09:13
  • 1
    Hey the sys/socket.h are Unix headers which are not available on Windows and that's why we're asked to install cygwin and gcc compiler. Into your `cyg-win64` directory open `setup-x86_64.exe` and install the `devel` package. Here's a tutorial https://www.youtube.com/watch?v=S3wm4Ytho4Q – Suhail Ahmed Aug 14 '22 at 03:17
  • Ok, I will try it. Thanks. But I think you should update the answer as well to mention about the cygwin – trungducng Aug 15 '22 at 09:17
  • it doesn't seem like a good idea to try to force something to work on windows which wasn't intended to work on windows, there are probably other linux dependencies for uwsgi which also won't be working. It's better to install WSL 2 https://learn.microsoft.com/en-us/windows/wsl/install-manual and install a linux app on windows, then go into your windows filesystem through the linux terminal – Conor Aug 25 '22 at 19:41