"Importerror: No Module Named Site" on Windows

Pip Error Import Error: No Module Named Site

I finally have got scrapy installed on my computer and below I outline the things I had to fix and tried for anyone else having similar issues. Please feel free to correct me or inform me of any redundant steps I may include

Thanks to yabberth for answering my question his method now works on my computer, but there were a few other things I had to fix up first to get things working (many of which seem obvious now in hindsight).

Environmental Variables

My environmental variables were not set up properly for a few reasons.

to access environmental variables I just search for "View Advanced System settings" in windows 10, I then click on Environmental variables. Then I see "User Variables" and "System Variables" both of which have a field called path. path is the field I will be modifying so I double click it on both and am presented with a list of paths.

  1. In both I include the path to where my Python is currently installed, which unlike most people for some reason is under C:\Users\MyUsername\AppData\Local\Programs\Python\Python37\
    as well as:
    C:\Users\cell\AppData\Local\Programs\Python\Python37\Scripts\

But it still wasn't working so:


  1. I currently have Python 3.7 installed, but previously had 3.6 and for some reason the paths for 3.6 were still there (not sure if the uninstall is meant to get rid of them or I was meant to do that). Once I deleted these pip started working again and I could install scrapy

After completing the above two steps I was able to install scrapy using windows command prompt using:

pip install scrapy

or as yabberth suggested on anaconda with

conda install -c conda-forge scrapy

Python - ImportError: No module named site

System had been trying to execute python.exe from a different source to where my new Python installation was. I believe it was trying to execute the python.exe stored with my version of PgAdmin.

Fix:
Move Python environment variables to the top of system variables

Python error ImportError: No module named

Based on your comments to orip's post, I guess this is what happened:

  1. You edited __init__.py on windows.
  2. The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).
  3. You used WinSCP to copy the file to your unix box.
  4. WinSCP thought: "This has something that's not basic text; I'll put a .bin extension to indicate binary data."
  5. The missing __init__.py (now called __init__.py.bin) means python doesn't understand toolkit as a package.
  6. You create __init__.py in the appropriate directory and everything works... ?


Related Topics



Leave a reply



Submit