nutti / fake-bpy-module

Fake Blender Python API module collection for the code completion.
MIT License
1.4k stars 98 forks source link

OSX Check if packages are installed 2.79 py 3.7.8 #73

Closed schroef closed 4 years ago

schroef commented 4 years ago

Bl 2.79 OSX 10.11.6 VSC 1.47.3

I was looking into to this last night and got it working after a while. Perhaps you could add some info about OSX that if a second pyhton is installed the paths are different. IE this line pip install fake-bpy-module-<version> only works if you have that main python as your default. I dont know much about this subject, so perhaps this makes sense for more accustomed users. I simply installed 3.7.8 and left 2.7 on the system as well. There for when i do pythion --version it returns 2.7

How can i check if the modules/packages are installed correct. Where are they actually installed if you use PIP?

nutti commented 4 years ago

@schroef

You can check the location where fake-bpy-module is installed by python -c "import bpy; print(bpy.__file__)". Or you can use pip freeze command whether fake-bpy-module is installed or not.

Be careful about the pip version which you try to install fake-bpy-module.

schroef commented 4 years ago

Yes I installed it first with pip and nothing showed me then I remembered that I specially need to address python3 so I did the same with pip making it pip3.

I think the first time it installed in the default 2.7, that's why I asked where this module is added so I can check if I installed it twice

nutti commented 4 years ago

Python 2.7 is not supported in fake-bpy-module because deps package does not support 2.7. (See requirement ) Also, Python 2.X will not more updated, so we don't support 2.X anymore.

nutti commented 4 years ago

@schroef

where this module is added

As I mentioned earlier, you can check the location by executing command python -c "import bpy; print(bpy.__file__)". Is there problem about this process?

grische commented 4 years ago

@schroef have you considered using a virtualenv? If you have never used it before, you might need to run pip3 install virtualenv,

You got into the workspace folder, then run the following commands

cd <into/the/folder/where/your/addon/code/resides>
python3 -m venv .venv
source .venv/bin/activate
pip install fake-bpy-module-<version>

This way you have a dedicated python environment in your .venv folder and your command python and pip will match to python3.

Many IDEs support the above .venv folder, like VSCode.

grische commented 4 years ago

@nutti the bug here is actually, that someone is able to install fake-bpy-module with python2. It should fail during the pip install step.

How to reproduce it:

$ python2 -m virtualenv .venv
Already using interpreter /usr/bin/python2
New python executable in /tmp/tmp.i1AYRijzPY/.venv/bin/python2
Also creating executable in /tmp/tmp.i1AYRijzPY/.venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.

$  .venv/bin/activate

(.venv) $ python -V
Python 2.7.17

(.venv) $ pip --version
pip 20.2.1 from /tmp/tmp.i1AYRijzPY/.venv/local/lib/python2.7/site-packages/pip (python 2.7)

(.venv) $ pip install fake-bpy-module-2.80
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting fake-bpy-module-2.80
  Downloading fake-bpy-module-2.80-20200724.tar.gz (574 kB)
     |████████████████████████████████| 574 kB 1.9 MB/s
  WARNING: Generating metadata for package fake-bpy-module-2.80 produced metadata for project name fake-bpy-module-80. Fix your #egg=fake-bpy-module-2.80 fragments.
Building wheels for collected packages: fake-bpy-module-80, fake-bpy-module-80
  Building wheel for fake-bpy-module-80 (setup.py) ... done
  Created wheel for fake-bpy-module-80: filename=fake_bpy_module_80-20200804-py2-none-any.whl size=682820 sha256=06a85ca607001660a2baa948d6d575f3414813b18ece9999391016fd5ed1a369
  Stored in directory: /home/grische/.cache/pip/wheels/8c/fd/75/5e652638a40fcca9f1830303c4b4e7f3433af93445e28b0a61
  Building wheel for fake-bpy-module-80 (setup.py) ... done
  Created wheel for fake-bpy-module-80: filename=fake_bpy_module_80-20200804-py2-none-any.whl size=682820 sha256=0cdcf7e944613bc43cfca9b9e4ecb338dfed0fd1d76a40ad2a8381e7f0866149
  Stored in directory: /home/grische/.cache/pip/wheels/51/80/b6/a26a68e246588d9f3e2cfc7d1ea7697140bad438435207ca84
Successfully built fake-bpy-module-80 fake-bpy-module-80
Installing collected packages: fake-bpy-module-80
Successfully installed fake-bpy-module-80-20200804

Successfully installed fake-bpy-module-80-20200804 😞

See here: https://packaging.python.org/guides/dropping-older-python-versions/

schroef commented 4 years ago

@schroef have you considered using a virtualenv? If you have never used it before, you might need to run pip3 install virtualenv,

You got into the workspace folder, then run the following commands

cd <into/the/folder/where/your/addon/code/resides>
python3 -m venv .venv
source .venv/bin/activate
pip install fake-bpy-module-<version>

This way you have a dedicated python environment in your .venv folder and your command python and pip will match to python3.

Many IDEs support the above .venv folder, like VSCode.

Thanks for the mention, I'm no developer and just get around. I got this working now, though I need to choose the proper python interpreter each time.

Will this environment be easier working?

grische commented 4 years ago

Thanks for the mention, I'm no developer and just get around. I got this working now, though I need to choose the proper python interpreter each time.

Will this environment be easier working?

Always depends on your workflow. If you use a virtualenv, you have to run source .venv/bin/activate every time you open a new shell before run any commands. Just try and see if it helps you.

nutti commented 4 years ago

@grische

Thanks for follow up comment. I could understand @schroef 's issue perfectly.

the bug here is actually, that someone is able to install fake-bpy-module with python2.

I agree fixing this issue. After I fixed some other issues, I will tackle this.

nutti commented 4 years ago

Fixed https://github.com/nutti/fake-bpy-module/commit/5a963d17a6ed1423711b132a44a7e7963ddc277e This patch already merged to master branch.

The result of a quick test is as follows. I used the artifact from GitHub Action. https://github.com/nutti/fake-bpy-module/actions/runs/195849894

$ python -V
Python 2.7.18 :: Anaconda, Inc.

$ pip install fake_bpy_module_2.83-20200805.dev65742-py3-none-any.whl
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
ERROR: fake_bpy_module_2.83-20200805.dev65742-py3-none-any.whl is not a supported wheel on this platform.
$ python -V
Python 3.7.7

$ pip install fake_bpy_module_2.83-20200805.dev65742-py3-none-any.whl
Processing fake_bpy_module_2.83-20200805.dev65742-py3-none-any.whl
Installing collected packages: fake-bpy-module-2.83
Successfully installed fake-bpy-module-2.83-20200805.dev65742
nutti commented 4 years ago

@schroef

I close this issue because the main issue is fixed. If you need more helps, feel free to reopen this issue or discuss at blender.chat. fake-bpy-module channel: https://blender.chat/channel/fake-bpy-module

schroef commented 4 years ago

Laat question, how can I check if something was installed first time. The paths of the default python are different then of that other method you showed

That command python -c.. return s "no module named boy". But during install no errors where printed. So I sort of guess it did install something

nutti commented 4 years ago

@schroef

But during install no errors where printed.

This is a bug of fake-bpy-module. From next release, the same command will output error.

That command python -c.. return s "no module named boy".

This is a correct behavior. But no error is printed in the installation process because this is a bug mentioned above.

You may use both command of python -V to know that the version is >=3.7 or not. If the version is >= 3.7, you can install fake-bpy-module.