Aug-30-2019, 03:17 PM
I don't know what your problem is now.
Can show a example with virtual environment,this is now build into Python trough venv.
Then use
Can maybe help looking at it from an other prescriptive.
See that work fine from my_code folder.
Can show a example with virtual environment,this is now build into Python trough venv.
Then use
selfwrittenmodule.py
my version that return something,your should also return something.# selfwrittenmodule.py def f1(x): x = x + 1 return xThis will be "like a" new python installation,separate from OS Python.
Can maybe help looking at it from an other prescriptive.
# Test python C:\data λ python -c "import sys; print(sys.executable)" C:\python37\python.exe # Test pip C:\data λ pip -V pip 19.2.1 from c:\python37\lib\site-packages\pip (python 3.7) # Make virtual environment C:\data λ python -m venv my_code # Cd in C:\data λ cd my_code # Activate see now (my_code) C:\data\my_code λ C:\data\my_code\Scripts\activate # Now will python and pip only point to this folder,as long as active (my_code) C:\data\my_code λ python -c "import sys; print(sys.executable)" C:\data\my_code\Scripts\python.exe (my_code) C:\data\my_code λ pip -V pip 19.0.3 from c:\data\my_code\lib\site-packages\pip (python 3.7)Now if save
selfwrittenmodule.py
in c:\data\my_code\lib\site-packages
See that work fine from my_code folder.
(my_code) C:\data\my_code λ python Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import selfwrittenmodule >>> >>> selfwrittenmodule.f1(999) 1000 # Placement >>> selfwrittenmodule.__file__ 'C:\\data\\my_code\\lib\\site-packages\\selfwrittenmodule.py' >>> exit()Install 3-party package eg Requests will aslo go into
site-packages
folder as all 3-party packages/modules dos.(my_code) C:\data\my_code λ pip install requests Collecting requests ..... Successfully installed certifi-2019.6.16 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.3Usage test:
(my_code) C:\data\my_code λ python Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> >>> r = requests.get('http://python-forum.io') >>> r.status_code 200 >>> r.text[494:520] 'Welcome to python-forum.io' # Placement >>> requests.__file__ 'C:\\data\\my_code\\lib\\site-packages\\requests\\__init__.py'