I'm trying to create a virtual environment to limit the size of an exe file I'm creating. However, when I create a virtual environment, it seems that it still adds packages that I haven't installed in the said environment.
I've tried to do a very small test file where I import numpy:
import numpy as np
A = np.array([0,0,1])
print(A)
When I create my virtual environment and run the script from cmd, it gets that numpy is not installed in the environment, but when I make the test script into an exe file using pyinstaller, somehow it gets numpy mixed into it all anyway... I have my entire cmd procedure here:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\MRCH>Virtualenv test_env
Using base prefix 'c:\\anaconda3'
New python executable in C:\Users\MRCH\test_env\Scripts\python.exe
Installing setuptools, pip, wheel...done.
C:\Users\MRCH>test_env\scripts\activate
(test_env) C:\Users\MRCH\dist>pip list
Package Version
---------- -------
pip 10.0.1
setuptools 39.2.0
wheel 0.31.1
(test_env) C:\Users\MRCH>python test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
(test_env) C:\Users\MRCH>pyinstaller test.py -y -F
454 INFO: PyInstaller: 3.3.1
...
132266 INFO: Appending archive to EXE C:\Users\MRCH\dist\test.exe
132473 INFO: Building EXE from out00-EXE.toc completed successfully.
(test_env) C:\Users\MRCH>cd dist
(test_env) C:\Users\MRCH\dist>test.exe
[0 0 1]
(test_env) C:\Users\MRCH\dist>
What am I doing wrong?