2

I created a virtual environment (venv64) for python 3.6.4. and installed ujson. It is installed in virtual environment site-packages.

But, when I am trying to import ujson in virtual env. It gives me an error:

ModuleNotFoundError: No module named 'ujson'

When I checked

sys.path

I got:

['', 'C:\\Python36\\python36.zip', 'C:\\Python36\\DLLs','C:\\Python36\\lib','C:\\Python36', 'C:\\Users\\Khushal Adlakha\\AppData\\Roaming\\Python\\Python36\\site-packages','C:\\Python36\\lib\\site-packages']

Instead it should be:

C:\Python36\venv64\Lib\site-packages

Why virtual environment is not using it's own site-packages?

pip freeze in venv shows:

certifi==2018.1.18
chardet==3.0.4 
cymem==1.31.2
cytoolz==0.8.2
dill==0.2.7.1
falcon==1.4.1
ftfy==4.4.3
html5lib==1.0b8
hug==2.4.0
hug-middleware-cors==1.0.0
idna==2.6
mmh3==2.5.1
msgpack-numpy==0.4.1
msgpack-python==0.5.4
murmurhash==0.28.0
numpy==1.14.1
pathlib==1.0.1
peewee==2.10.2
plac==0.9.6
preshed==1.0.0
prodigy==1.3.0
pyreadline==2.1
python-mimeparse==1.6.0
regex==2017.4.5
requests==2.18.4
six==1.11.0
spacy==2.0.9
termcolor==1.1.0
thinc==6.10.2
toolz==0.9.0
tqdm==4.19.6
ujson==1.35
urllib3==1.22
waitress==1.1.0
wcwidth==0.1.7
wrapt==1.10.11
  • Windows 10 64-bit
  • Python 3.6.4 (64-bit)
James Z
  • 12,209
  • 10
  • 24
  • 44
  • Did you activate your venv when you installed ujson? Did you activate it when you ran your script? – Code-Apprentice Feb 27 '18 at 20:53
  • @Code-Apprentice - Hi, yes, it was in activate mode at both the times. – Khushal Adlakha Feb 27 '18 at 20:57
  • Can You show `pip freeze` from venv? How do You run the .py file that causes the error? to run from venv:`/path/venv/Scripts/pip freeze` `path/venv/Scripts/python3 file.py` on Linux change `Scripts` in path to `bin` – Lukasz Feb 27 '18 at 20:59
  • @Lukasz Are you assuming that the venv is activated? – Code-Apprentice Feb 27 '18 at 21:12
  • @Lukasz - I have included the pip freeze results in the post. I didn't got your second question. – Khushal Adlakha Feb 27 '18 at 21:26
  • second command was just to be sure You are using venv when running .py file (even if is said to be active) – Lukasz Mar 01 '18 at 07:38
  • Could You please insert import code and file structure? See this for reference: https://stackoverflow.com/questions/48895867/jump-to-declaration-when-file-is-in-another-folder-directory/48896111?noredirect=1#comment84798175_48896111 – Lukasz Mar 01 '18 at 20:17

0 Answers0