我对通过pyenv / pip安装的路径上的可执行文件感到困惑。故事始于我在给定的程序包中有多个python解释器。今天,我了解了class Main extends React.Component {
state = { currentUser: null, chatData:[]}
componentDidMount = () => {
console.log('A - component did mount')
// definitely works
this.willFocusSubscription = this.props.navigation.addListener(
'willFocus',
payload => {
console.log('A- focus')
this.readCourseData()
})
this.willBlurSubscription = this.props.navigation.addListener(
'willBlur',
payload => {
console.log('A- blur')
this.setState({chatData: []})
})
}
componentWillUnmount() {
console.log('A - component will unmount')
this.willFocusSubscription.remove();
this.willBlurSubscription.remove();
// Remove the event listener
}
readCourseData = () => {
// Make call to Cloud Firestore
// for the current user, retrieve the chat document associated with each element in the chats array
let user = firebase.auth().currentUser;
firestore().collection("users").doc(user.uid).get().then((doc) => {
doc.data().chats.map((element) => {
firestore().collection("chats").doc(element).get().then((doc) => {
let newArray = [...this.state.chatData, { id: element, subject: doc.data().subject, course: doc.data().course }]
let uniqueArray = [...new Set(newArray)]
this.setState({
chatData: uniqueArray
})
})
});
})
}
,它应该为我提供一个由python软件包(可执行文件)组成的独立于系统的可执行文件。安装软件包后,pipx会警告我它已经存在。但是,尚不清楚如何在我的路径上摆脱它,以便能够使用正确的新可执行文件。
我尝试从字面上删除在重复路径上发现的文件,这导致了以下有趣的情况:
pipx
my_machine:proj_a ikkamens$ pipx install flynt --python python3.8
⚠️ Note: flynt was already on your PATH at /Users/ikkamens/.pyenv/shims/flynt
installed package flynt 0.40.1, Python 3.8.0
These apps are now globally available
- flynt
done! ✨ ? ✨
my_machine:proj_a ikkamens$ flynt --help
pyenv: flynt: command not found
The 'flynt' command exists in these Python versions:
3.6.8/envs/blues
3.7.3
3.8-dev
blues
my_machine:proj_a ikkamens$ rm /Users/ikkamens/.pyenv/shims/flynt
my_machine:proj_a ikkamens$ flynt
-bash: /Users/ikkamens/.pyenv/shims/flynt: No such file or directory
my_machine:proj_a ikkamens$ cd
my_machine:~ ikkamens$ cat .bashrc | grep fl
my_machine:~ ikkamens$ which flynt
/Users/ikkamens/.local/bin/flynt
my_machine:~ ikkamens$ flynt
-bash: /Users/ikkamens/.pyenv/shims/flynt: No such file or directory
可能返回与执行的结果不同的结果吗?请注意,我的.bashrc不包含任何别名或类似名称(grep语句)。如何完全摆脱旧安装的剩余内容?
答案 0 :(得分:1)
如@jordanm所评论,该问题归因于bash哈希PATH查找。
my_machine:~ ikkamens$ rm /Users/ikkamens/.pyenv/shims/flynt
my_machine:~ ikkamens$ flynt
-bash: /Users/ikkamens/.pyenv/shims/flynt: No such file or directory
my_machine:~ ikkamens$ which flynt
/Users/ikkamens/.local/bin/flynt
my_machine:~ ikkamens$ hash -r
my_machine:~ ikkamens$ flynt
Running flynt v.0.40.1
答案 1 :(得分:0)
使用pyenv,您可以拥有不同的隔离python环境。首先,您必须激活一种pyenv环境:
# check which virtual environments you have
pyenv virtualenvs
# activate one
pyenv activate blues
# seems that `blues` is your virtual environment with python 3.6.8
# then install your package into active virtual environment
pip install flynt
# also uninstall packages while being in your environment