简体   繁体   English

使用python3.9手动安装模块

[英]Manually installing modules with python3.9

My usual workflow for manually installing python modules doesn't work since I upgraded to python3.9 on my mac.自从我在 mac 上升级到 python3.9 后,我通常手动安装 python 模块的工作流程不起作用。 Suppose I want to install a custom module called "myfiles" from the setup script, I do假设我想从安装脚本中安装一个名为“myfiles”的自定义模块,我这样做

cd myfiles
python3 setup.py install --user

The output contains the line output 包含该行

Extracting myfiles-1.6.1-py3.9.egg to /Users/antonius/Library/Python/3.9/lib/python3.9/site-packages

When I inspect the content of sys.path , I see the directory当我检查sys.path的内容时,我看到了目录

/Users/antonius/Library/Python/3.9/lib/python/site-packages

as well as all other directories under it.以及它下面的所有其他目录。 However, the directory然而,目录

/Users/antonius/Library/Python/3.9/lib/python3.9/site-packages

does not appear in the list of paths.不会出现在路径列表中。 Even if I edit my ~/.zshrc to include the line即使我编辑我的~/.zshrc以包含该行

export PYTHONPATH="/Users/antonius/Library/Python/3.9/lib/python3.9/site-packages:$PYTHONPATH"

then the list of paths contains this directory, but does not contain any of the directories under it, so I cannot import my module.然后路径列表包含此目录,但不包含其下的任何目录,因此我无法导入我的模块。

What is going on?到底是怎么回事? How do I tell python to expand the list of paths from the content of the site-packages/ directory?我如何告诉 python 从site-packages/目录的内容展开路径列表? Even then, it doesn't seem right that I need to add that path in my ~/.zshrc .即便如此,我需要在我的~/.zshrc中添加该路径似乎也不对。

Btw, the content of my ~/.pydistutils.cfg file is just顺便说一句,我的~/.pydistutils.cfg文件的内容只是

[install]
prefix=

Use pip .使用pip pip install --user. will do the same thing.会做同样的事情。 setup.py is deprecated. setup.py 已弃用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM